Skip to content

Commit

Permalink
requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedaei79 committed Jun 2, 2020
1 parent 61f7581 commit 4966bd2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/database.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"allUsers":{"admin1":{"personalInfo":"{\"username\":\"a\",\"firstName\":\"a\",\"lastName\":\"a\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"11111\",\"password\":\"a\"}"}},"requestedSellers":{"seller2":{"personalInfo":"{\"username\":\"s\",\"firstName\":\"s\",\"lastName\":\"s\",\"emailAddress\":\"[email protected]\",\"phoneNumber\":\"11111\",\"password\":\"s\"}","listOfOffs":"[]","balance":"0","listOfSellLogs":"[]","availableProducts":"{}","company":"c"}},"allCodedDiscounts":{},"allCategories":{},"mainCategories":{},"allProducts":{},"allLogs":{},"allOffs":{},"allRequests":{"seller register1":{"seller":"seller2","fieldsAndValues":"null","id":"seller register1","requestStatus":"null"}},"allProductSellInfos":{},"allRates":{},"allCompanies":[],"idKeeper":{"usersNewId":2,"codedDiscountsNewId":0,"categoriesNewId":0,"productsNewId":0,"logsNewId":0,"offsNewId":0,"requestsNewId":1,"productSellInfosNewId":0,"ratesNewId":0}}
18 changes: 9 additions & 9 deletions src/main/java/model/MarketCopier.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ public class MarketCopier { // copies and rebuilds market
private static MarketCopier instance = new MarketCopier();
private static Market market = Market.getInstance();
private HashMap<String, HashMap<String, String>> allUsers;// configure type by Id
private HashMap<String, HashMap> requestedSellers;
private HashMap<String, HashMap<String, String>> requestedSellers;
private HashMap<String, HashMap> allCodedDiscounts;
private HashMap<String, HashMap<String, String>> allCategories; // configure type by Id
private HashMap<String, HashMap> mainCategories; // be made from allCategories
private HashMap<String, HashMap> allProducts;
private HashMap<String, HashMap> allLogs;
private HashMap<String, HashMap> allOffs;
private HashMap<String, HashMap> allRequests; // configure type by Id
private HashMap<String, HashMap<String, String>> allRequests; // configure type by Id
private HashMap<String, HashMap> allProductSellInfos; // add news to it
private HashMap<String, HashMap> allRates;
private ArrayList<Company> allCompanies;
Expand Down Expand Up @@ -67,9 +67,9 @@ public void copyMarket() {
allCategories = buildIdToObjectHashMapHashMap(market.getAllCategories());
// mainCategories = buildIdToObjectHashMapHashMap(market.getMainCategories());
// allProducts = buildIdToObjectHashMapHashMap(market.getAllProducts());
// allRequests = buildIdToObjectHashMapHashMap(market.getAllRequests());
allRequests = buildIdToObjectHashMapHashMap(market.getAllRequests());
// allProductSellInfos = buildIdToObjectHashMapHashMap(market.getAllProductSellInfos());
// requestedSellers = buildIdToObjectHashMapHashMap(market.getRequestedSellers());
requestedSellers = buildIdToObjectHashMapHashMap(market.getRequestedSellers());
// allRates = buildIdToObjectHashMapHashMap(market.getAllRates());
// allCompanies = market.getAllCompanies();
}
Expand All @@ -90,9 +90,9 @@ public void buildMarketWithIds() {
market.setAllCategories(buildArrayListOfPrimaryCategories(allCategories.keySet()));
// market.setMainCategories(buildArrayListOfPrimaryCategories(mainCategories.keySet()));
// market.setAllProducts(buildArrayListOfPrimaryObjects(Product.class, allProducts.keySet()));
// market.setAllRequests(buildArrayListOfPrimaryRequests(allRequests.keySet()));
market.setAllRequests(buildArrayListOfPrimaryRequests(allRequests.keySet()));
// market.setAllProductSellInfos(buildArrayListOfPrimaryObjects(ProductSellInfo.class, allProductSellInfos.keySet()));
// market.setRequestedSellers(buildArrayListOfPrimaryObjects(Seller.class, requestedSellers.keySet()));
market.setRequestedSellers(buildArrayListOfPrimaryObjects(Seller.class, requestedSellers.keySet()));
// market.setAllRates(buildArrayListOfPrimaryObjects(Rate.class, allRates.keySet()));
// market.setAllCompanies(allCompanies);
// IdKeeper.setInstance(idKeeper);
Expand Down Expand Up @@ -174,14 +174,14 @@ private ArrayList<Request> buildArrayListOfPrimaryRequests(Set<String> set) {

public void buildMarketWithHashMaps() {
buildUsersWithHashMaps();
// buildRequestedSellersWithHashMaps();
buildRequestedSellersWithHashMaps();
// buildDiscountsWithHashMaps();
buildCategoriesWithHashMaps();
// buildMainCategoriesWithHashMaps();
// buildProductsWithHashMaps();
// buildLogsWithHashMaps();
// buildOffsWithHashMaps();
// buildRequestsWithHashMaps();
buildRequestsWithHashMaps();
// buildProductSellInfosWithHashMaps();
// buildRatesWithHashMaps();
}
Expand Down Expand Up @@ -245,7 +245,7 @@ private void buildOffsWithHashMaps() {
private void buildRequestsWithHashMaps() {
for (String id : allRequests.keySet()) {
Request request = Market.getInstance().getRequestById(id);
// request.setFieldsFromHashMap(allRequests.get(id));
request.setFieldsFromHashMap(allRequests.get(id));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/model/user/Seller.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void setFieldsFromHashMap(HashMap<String, String> theMap) {
// }

availableProducts = new HashMap<>();
HashMap<String, String> products = (new Gson()).fromJson(theMap.get("availableProducts"), new TypeToken<ArrayList<String>>(){}.getType());
HashMap<String, String> products = (new Gson()).fromJson(theMap.get("availableProducts"), new TypeToken<HashMap<String, String>>(){}.getType());
for (String productId : products.keySet()) {
availableProducts.put(Market.getInstance().getProductById(productId),
Market.getInstance().getProductSellInfoById(products.get(productId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public RequestsManagingMenu() {
super("requests managing menu");
this.manager = RequestController.getInstance();
this.managingObject = "Requests";
submenus.put("details (\\S+)", createOneItemDisplayPanel("request", (Printer) manager));
submenus.put("(accept|decline) (\\S+)", getAcceptDeclinePanel());
submenus.put("details (.+)", createOneItemDisplayPanel("request", (Printer) manager));
submenus.put("(accept|decline) (.+)", getAcceptDeclinePanel());
}

private Panel getAcceptDeclinePanel(){
Expand Down

0 comments on commit 4966bd2

Please sign in to comment.