Rev 21873 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.inventory.utils;import in.shop2020.model.v1.inventory.StateInfo;import in.shop2020.purchase.Supplier;import in.shop2020.purchase.PurchaseService.Client;import in.shop2020.thrift.clients.InventoryClient;import in.shop2020.thrift.clients.PurchaseClient;import java.util.Collections;import java.util.List;import java.util.Map;import org.slf4j.Logger;import org.slf4j.LoggerFactory;public class Utils {private static Map<Long, StateInfo> stateIdMap=null;private static List<Supplier> suppliers = null;private static Logger logger = LoggerFactory.getLogger(Utils.class);static {try {in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();stateIdMap = inventoryClient.getStateMaster();} catch (Exception e) {logger.error("Unable to get State Info Map", e);}}public static Map<Long, StateInfo> getStateIdMap() {if (stateIdMap == null) {try {in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();stateIdMap = Collections.unmodifiableMap(inventoryClient.getStateMaster());} catch (Exception e) {logger.error("Unable to get State Info Map", e);}}return stateIdMap;}public static List<Supplier> getSuppliers() {if (suppliers == null) {try {Client purchaseClient = new PurchaseClient().getClient();suppliers = purchaseClient.getAllSuppliers();} catch (Exception e) {logger.error("Error loading suppliers", e);}}return suppliers;}public static void resetSuppliers(){suppliers = null;}}