| Line 14... |
Line 14... |
| 14 |
import java.util.Map;
|
14 |
import java.util.Map;
|
| 15 |
|
15 |
|
| 16 |
import com.google.gwt.core.client.GWT;
|
16 |
import com.google.gwt.core.client.GWT;
|
| 17 |
|
17 |
|
| 18 |
public class CatalogUtils {
|
18 |
public class CatalogUtils {
|
| - |
|
19 |
|
| - |
|
20 |
private static Map<Long, Map<Long, Warehouse>> billingWarehouseMap = new HashMap<Long, Map<Long,Warehouse>>();
|
| - |
|
21 |
private static Map<Long, Map<Long, String>> billingWarehouseNameMap = new HashMap<Long, Map<Long,String>>();
|
| 19 |
public static List<Item> getAllItems(){
|
22 |
public static List<Item> getAllItems(){
|
| 20 |
List<Item> itemList = new ArrayList<Item>();
|
23 |
List<Item> itemList = new ArrayList<Item>();
|
| 21 |
|
24 |
|
| 22 |
try {
|
25 |
try {
|
| 23 |
CatalogClient catalogServiceClient = new CatalogClient();
|
26 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| Line 99... |
Line 102... |
| 99 |
}
|
102 |
}
|
| 100 |
return null;
|
103 |
return null;
|
| 101 |
}
|
104 |
}
|
| 102 |
|
105 |
|
| 103 |
public static Map<Long, String> getWarehousesForBillingWarehouse(long warehouseId){
|
106 |
public static Map<Long, String> getWarehousesForBillingWarehouse(long warehouseId){
|
| - |
|
107 |
if(billingWarehouseNameMap.get(warehouseId)==null){
|
| 104 |
try{
|
108 |
try{
|
| 105 |
InventoryClient catalogServiceClient = new InventoryClient();
|
- |
|
| 106 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
- |
|
| 107 |
List<Warehouse> warehouses = catalogClient.getWarehouses(null, InventoryType.GOOD, 0, warehouseId, 0);
|
109 |
Map<Long, Warehouse> warehouseMap = getAllWarehousesForBillingWarehouse(warehouseId);
|
| 108 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
110 |
Map<Long, String> warehouseNameMap = new HashMap<Long, String>();
|
| 109 |
for(Warehouse warehouse: warehouses){
|
111 |
for(Warehouse warehouse: warehouseMap.values()){
|
| 110 |
warehouseMap.put(warehouse.getId(), warehouse.getDisplayName());
|
112 |
warehouseNameMap.put(warehouse.getId(), warehouse.getDisplayName());
|
| - |
|
113 |
}
|
| - |
|
114 |
billingWarehouseNameMap.put(warehouseId, warehouseNameMap);
|
| - |
|
115 |
}catch(Exception e){
|
| - |
|
116 |
e.printStackTrace();
|
| 111 |
}
|
117 |
}
|
| 112 |
return warehouseMap;
|
- |
|
| 113 |
}catch(Exception e){
|
118 |
} else {
|
| 114 |
// TODO: Oops! We couldn't reduce the item reservation count. This will
|
- |
|
| 115 |
// result in underestimation of inventory stock. Should be corrected
|
- |
|
| 116 |
// periodically.
|
119 |
|
| 117 |
e.printStackTrace();
|
- |
|
| 118 |
}
|
120 |
}
|
| 119 |
return null;
|
121 |
return billingWarehouseNameMap.get(warehouseId);
|
| 120 |
}
|
122 |
}
|
| 121 |
|
123 |
|
| 122 |
public static Map<Long, Warehouse> getAllWarehousesForBillingWarehouse(long warehouseId){
|
124 |
public static Map<Long, Warehouse> getAllWarehousesForBillingWarehouse(long warehouseId){
|
| - |
|
125 |
if(billingWarehouseMap.get(warehouseId)==null) {
|
| 123 |
try{
|
126 |
try{
|
| 124 |
InventoryClient catalogServiceClient = new InventoryClient();
|
127 |
InventoryClient catalogServiceClient = new InventoryClient();
|
| 125 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
128 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 126 |
List<Warehouse> warehouses = catalogClient.getWarehouses(null, InventoryType.GOOD, 0, warehouseId, 0);
|
129 |
List<Warehouse> warehouses = catalogClient.getWarehouses(null, InventoryType.GOOD, 0, warehouseId, 0);
|
| - |
|
130 |
|
| 127 |
Map<Long, Warehouse> warehouseMap = new HashMap<Long, Warehouse>();
|
131 |
Map<Long, Warehouse> map = new HashMap<Long, Warehouse>();
|
| 128 |
for(Warehouse warehouse: warehouses){
|
132 |
for(Warehouse warehouse: warehouses){
|
| 129 |
warehouseMap.put(warehouse.getId(), warehouse);
|
133 |
map.put(warehouse.getId(), warehouse);
|
| - |
|
134 |
}
|
| - |
|
135 |
billingWarehouseMap.put(warehouseId, map);
|
| - |
|
136 |
}catch(Exception e){
|
| - |
|
137 |
e.printStackTrace();
|
| 130 |
}
|
138 |
}
|
| 131 |
return warehouseMap;
|
- |
|
| 132 |
}catch(Exception e){
|
- |
|
| 133 |
// TODO: Oops! We couldn't reduce the item reservation count. This will
|
- |
|
| 134 |
// result in underestimation of inventory stock. Should be corrected
|
- |
|
| 135 |
// periodically.
|
- |
|
| 136 |
e.printStackTrace();
|
- |
|
| 137 |
}
|
139 |
}
|
| 138 |
return null;
|
140 |
return billingWarehouseMap.get(warehouseId);
|
| 139 |
}
|
141 |
}
|
| 140 |
|
142 |
|
| 141 |
public static Warehouse getWarehouse(long warehouseId) {
|
143 |
public static Warehouse getWarehouse(long warehouseId) {
|
| 142 |
try{
|
144 |
try{
|
| 143 |
InventoryClient catalogServiceClient = new InventoryClient();
|
145 |
InventoryClient catalogServiceClient = new InventoryClient();
|