Skip to content

Commit

Permalink
init for tag
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkan-khd committed Jun 26, 2020
1 parent 4f9c5d0 commit 113fc03
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 959 deletions.
1 change: 0 additions & 1 deletion src/main/java/controller/Control.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ else if(minPrice > maxPrice)
else {
filter.minPrice = minPrice;
filter.maxPrice = maxPrice;
System.out.println(filter.minPrice + " " + filter.maxPrice);
return Notification.SET_PRICE_FILTERS;
}
}
Expand Down
64 changes: 0 additions & 64 deletions src/main/java/controller/account/AccountControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,6 @@ public Notification modifyApprove(String username, int flag) {
}
}

public ArrayList<String> getUnapprovedUsernames() {
ArrayList<String> allUsernames = new ArrayList<>();
try {

for (Account account : VendorTable.getUnApprovedVendors()) {
allUsernames.add(account.getUsername());
}
return allUsernames;
} catch (SQLException throwables) {
throwables.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}

public static AccountControl getController() {
if (customerControl == null)
customerControl = new AccountControl();
Expand All @@ -218,22 +201,6 @@ public ArrayList<Account> getAllAccounts() {
}
}

public ArrayList<String> getAllUsernames() {
ArrayList<String> allUsernames = new ArrayList<>();
try {
for (Account account : AccountTable.getAllUsers()) {
allUsernames.add(account.getUsername());
}
return allUsernames;
} catch (SQLException e) {
e.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public Notification deleteUserWithUsername(String username){
try {
if(getAccountByUsername(username).getType().equals("Vendor")) {
Expand Down Expand Up @@ -266,37 +233,6 @@ public Notification deleteUserWithUsername(String username){
}
}

public ArrayList<String> getAdminsUsernames(){
ArrayList<String> adminsUsernames = new ArrayList<>();
try {
for (Account admin : AccountTable.getAllAdmins()) {
adminsUsernames.add(admin.getUsername());
}
return adminsUsernames;
} catch (SQLException throwable) {
throwable.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public ArrayList<String> getAllCustomerNames() {
ArrayList<String> allCustomers = new ArrayList<>();
try {
for(Account account : AccountTable.getAllCustomers())
{
allCustomers.add(account.getUsername());
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return allCustomers;
}

public Off getOffByID(String offID) {
try {
Off off = OffTable.getSpecificOff(offID);
Expand Down
226 changes: 0 additions & 226 deletions src/main/java/controller/account/AdminControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,24 +67,6 @@ public boolean isUserAddedInDiscount(Discount discount, String userName) {
return false;
}

public ArrayList<String> getAllCategoryNames() {
try {
ArrayList<String> categories = new ArrayList<>();
for (Category category : CategoryTable.getAllCategories()) {
categories.add(category.getName());
}

categories.remove("All Products");
return categories;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return new ArrayList<>();
}

public Notification addCategory(Category category)
{
try {
Expand Down Expand Up @@ -258,36 +240,6 @@ public ArrayList<Discount> getAllDiscounts() {
return new ArrayList<>();
}

public ArrayList<String> getAllDiscountCodes() {
ArrayList<String> discountCodes = new ArrayList<>();
try {
DiscountTable.updateDiscountCodesTime();
for (Discount discountCode : DiscountTable.getAllDiscountCodes()) {
discountCodes.add(discountCode.getCode());
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return discountCodes;
}


public ArrayList<String> getAllDiscountIDs() {
ArrayList<String> discountCodes = new ArrayList<>();
try {
for (Discount discountCode : DiscountTable.getAllDiscountCodes()) {
discountCodes.add(discountCode.getID());
}
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return discountCodes;
}

public Discount getDiscountByID(String ID) {
try {
return DiscountTable.getDiscountByID(ID);
Expand Down Expand Up @@ -371,105 +323,6 @@ private String generateDiscountID() {
return ID.toString();
}

public Notification editDiscountCode(String ID, String code) {
try {
if (code.length() > 16 || code.length() < 6)
return Notification.INVALID_DISCOUNT_CODE;
else if (DiscountTable.getDiscountByID(ID).getCode().equals(code))
return Notification.SAME_FIELD_ERROR;
else
DiscountTable.editCode(ID, code);

return Notification.EDIT_FIELD_SUCCESSFULLY;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return null;
}

public Notification editFinishDate(String ID, Date finishDate) {
try {
Date currentDate = new Date(new java.util.Date().getTime());

if (finishDate.compareTo(DiscountTable.getDiscountByID(ID).getStartDate()) != +1)
return Notification.INVALID_FINISH_DATE_EARLIER_THAN_START_DATE;
else if (finishDate.compareTo(currentDate) != +1)
return Notification.INVALID_FINISH_DATE_EARLIER_THAN_CURRENT_DATE;
else if (DiscountTable.getDiscountByID(ID).getFinishDate().equals(finishDate))
return Notification.SAME_FIELD_ERROR;
else
DiscountTable.editFinishDate(ID, finishDate);

return Notification.EDIT_FIELD_SUCCESSFULLY;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return null;
}

public Notification editDiscountPercent(String ID, double discountPercent) {
try {
if (discountPercent > 100 || discountPercent <= 0)
return Notification.INVALID_DISCOUNT_PERCENT;
else if (DiscountTable.getDiscountByID(ID).getDiscountPercent() == discountPercent)
return Notification.SAME_FIELD_ERROR;
else
DiscountTable.editDiscountPercent(ID, discountPercent);

return Notification.EDIT_FIELD_SUCCESSFULLY;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return null;
}

public Notification editMaxDiscount(String ID, double maxDiscount) {
try {
if (maxDiscount <= 0)
return Notification.INVALID_MAX_DISCOUNT;
else if (DiscountTable.getDiscountByID(ID).getMaxDiscount() == maxDiscount)
return Notification.SAME_FIELD_ERROR;
else
DiscountTable.editMaxDiscount(ID, maxDiscount);

return Notification.EDIT_FIELD_SUCCESSFULLY;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return null;
}

public Notification editMaxRepetition(String ID, int maxRepetition) {
try {
if (maxRepetition <= 0)
return Notification.INVALID_MAX_REPETITION;
else if (DiscountTable.getDiscountByID(ID).getMaxRepetition() == maxRepetition)
return Notification.SAME_FIELD_ERROR;
else
DiscountTable.editMaxRepetition(ID, maxRepetition);

return Notification.EDIT_FIELD_SUCCESSFULLY;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}

return null;
}

public ArrayList<Off> getAllUnApprovedOffs() {
try {
return OffTable.getAllUnApprovedOffs();
Expand All @@ -481,30 +334,6 @@ public ArrayList<Off> getAllUnApprovedOffs() {
return new ArrayList<>();
}

public ArrayList<String> getAllUnApprovedOffNames(){
try {
return OffTable.getAllUnApprovedOffNames();
} catch (SQLException e) {
e.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public ArrayList<String> getAllUnApprovedOffIDs(){
try {
return OffTable.getAllUnApprovedOffIDs();
} catch (SQLException e) {
e.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public Notification modifyOffApprove(String offID, boolean flag){
try {
if (flag){
Expand All @@ -521,30 +350,6 @@ public Notification modifyOffApprove(String offID, boolean flag){
}
}

public ArrayList<String> getAllEditingOffNames() {
try {
return OffTable.getEditingOffNames();
} catch (SQLException e) {
e.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public ArrayList<String> getAllEditingOffIDs() {
try {
return OffTable.getEditingOffIDs();
} catch (SQLException e) {
e.printStackTrace();
return new ArrayList<>();
} catch (ClassNotFoundException e) {
e.printStackTrace();
return new ArrayList<>();
}
}

public Notification modifyOffEditingApprove(String offID, boolean isAccepted)
{
try {
Expand Down Expand Up @@ -602,36 +407,6 @@ public ArrayList<Comment> getAllUnApprovedComments() {
return new ArrayList<>();
}

public ArrayList<String> getAllUnApprovedCommentTitles(){
try {
ArrayList<String> allUnApprovedCommentTitles = new ArrayList<>();
for (Comment unApprovedComment : ProductTable.getAllUnApprovedComments()) {
allUnApprovedCommentTitles.add(unApprovedComment.getTitle());
}
return allUnApprovedCommentTitles;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return new ArrayList<>();
}

public ArrayList<String> getAllUnApprovedCommentIDs(){
try {
ArrayList<String> allUnApprovedCommentIDs = new ArrayList<>();
for (Comment unApprovedComment : ProductTable.getAllUnApprovedComments()) {
allUnApprovedCommentIDs.add(unApprovedComment.getCommentID());
}
return allUnApprovedCommentIDs;
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return new ArrayList<>();
}

public Notification modifyCommentApproval(String commentID, boolean flag){
try {
if (flag){
Expand Down Expand Up @@ -715,7 +490,6 @@ public Notification modifyProductApprove(String productID, boolean approved) {
return ProductControl.getController().removeProductById(productID);
}


private Notification approveProductByID(String id){
try {
ProductTable.setProductStatus(id, 1);
Expand Down
Loading

0 comments on commit 113fc03

Please sign in to comment.