Subversion Repositories SmartDukaan

Rev

Rev 4555 | Rev 5185 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4555 Rev 5110
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.warehouse.domain;
4
package in.shop2020.warehouse.domain;
5
 
5
 
-
 
6
import in.shop2020.generic.ExceptionType;
6
import in.shop2020.purchase.LineItem;
7
import in.shop2020.purchase.LineItem;
7
import in.shop2020.purchase.PurchaseOrder;
8
import in.shop2020.purchase.PurchaseOrder;
8
import in.shop2020.purchase.PurchaseService.Client;
9
import in.shop2020.purchase.PurchaseService.Client;
9
import in.shop2020.thrift.clients.PurchaseClient;
10
import in.shop2020.thrift.clients.PurchaseClient;
-
 
11
import in.shop2020.warehouse.WarehouseServiceException;
10
 
12
 
11
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
14
import org.apache.commons.logging.LogFactory;
13
import org.apache.thrift.TException;
-
 
14
import org.apache.thrift.transport.TTransportException;
-
 
15
 
15
 
16
 
16
 
17
/**
17
/**
18
 * @author mandeep
18
 * @author mandeep
19
 *
19
 *
Line 40... Line 40...
40
        inventoryItem.purchaseId = thriftInventoryItem.getPurchaseId();
40
        inventoryItem.purchaseId = thriftInventoryItem.getPurchaseId();
41
 
41
 
42
        return inventoryItem;
42
        return inventoryItem;
43
    }
43
    }
44
 
44
 
45
    public in.shop2020.warehouse.InventoryItem convert() {
45
    public in.shop2020.warehouse.InventoryItem convert() throws WarehouseServiceException {
46
        in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
46
        in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
47
        inventoryItem.setId(id);
47
        inventoryItem.setId(id);
48
        inventoryItem.setItemId(itemId);
48
        inventoryItem.setItemId(itemId);
49
        inventoryItem.setCurrentQuantity(currentQuantity);
49
        inventoryItem.setCurrentQuantity(currentQuantity);
50
        inventoryItem.setInitialQuantity(initialQuantity);
50
        inventoryItem.setInitialQuantity(initialQuantity);
Line 61... Line 61...
61
                if (lineItem.getItemId() == itemId) {
61
                if (lineItem.getItemId() == itemId) {
62
                    inventoryItem.setUnitPrice(lineItem.getUnitPrice());
62
                    inventoryItem.setUnitPrice(lineItem.getUnitPrice());
63
                    break;
63
                    break;
64
                }
64
                }
65
            }
65
            }
66
        } catch (TTransportException e) {
-
 
67
            logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
-
 
68
        } catch (TException e) {
66
        } catch (Exception e) {
69
            logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
67
            logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
-
 
68
            throw new WarehouseServiceException(ExceptionType.DATABASE_ERROR, "Could not find item in PO.");
70
        }
69
        }
71
 
70
 
72
        return inventoryItem;
71
        return inventoryItem;
73
    }
72
    }
74
 
73