| 21873 |
amit.gupta |
1 |
package in.shop2020.inventory.utils;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.inventory.StateInfo;
|
|
|
4 |
import in.shop2020.purchase.Supplier;
|
|
|
5 |
import in.shop2020.purchase.PurchaseService.Client;
|
|
|
6 |
import in.shop2020.thrift.clients.InventoryClient;
|
|
|
7 |
import in.shop2020.thrift.clients.PurchaseClient;
|
|
|
8 |
|
|
|
9 |
import java.util.Collections;
|
|
|
10 |
import java.util.List;
|
|
|
11 |
import java.util.Map;
|
|
|
12 |
|
|
|
13 |
import org.slf4j.Logger;
|
|
|
14 |
import org.slf4j.LoggerFactory;
|
|
|
15 |
|
|
|
16 |
public class Utils {
|
|
|
17 |
|
|
|
18 |
private static Map<Long, StateInfo> stateIdMap=null;
|
|
|
19 |
private static List<Supplier> suppliers = null;
|
|
|
20 |
private static Logger logger = LoggerFactory.getLogger(Utils.class);
|
|
|
21 |
|
|
|
22 |
static {
|
|
|
23 |
try {
|
|
|
24 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
25 |
stateIdMap = inventoryClient.getStateMaster();
|
|
|
26 |
|
|
|
27 |
} catch (Exception e) {
|
|
|
28 |
logger.error("Unable to get State Info Map", e);
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
public static Map<Long, StateInfo> getStateIdMap() {
|
| 21875 |
amit.gupta |
33 |
if (stateIdMap == null) {
|
| 21873 |
amit.gupta |
34 |
try {
|
|
|
35 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
36 |
stateIdMap = Collections.unmodifiableMap(inventoryClient.getStateMaster());
|
|
|
37 |
|
|
|
38 |
} catch (Exception e) {
|
|
|
39 |
logger.error("Unable to get State Info Map", e);
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
return stateIdMap;
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
public static List<Supplier> getSuppliers() {
|
| 21875 |
amit.gupta |
47 |
if (suppliers == null) {
|
| 21873 |
amit.gupta |
48 |
try {
|
|
|
49 |
Client purchaseClient = new PurchaseClient().getClient();
|
|
|
50 |
suppliers = purchaseClient.getAllSuppliers();
|
|
|
51 |
} catch (Exception e) {
|
|
|
52 |
logger.error("Error loading suppliers", e);
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
return suppliers;
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
public static void resetSuppliers(){
|
|
|
60 |
suppliers = null;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
}
|