Subversion Repositories SmartDukaan

Rev

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

Rev 8286 Rev 8303
Line 7... Line 7...
7
 
7
 
8
import java.io.File;
8
import java.io.File;
9
import java.io.FileInputStream;
9
import java.io.FileInputStream;
10
import java.io.IOException;
10
import java.io.IOException;
11
import java.text.SimpleDateFormat;
11
import java.text.SimpleDateFormat;
12
import java.util.Collection;
-
 
13
import java.util.Date;
12
import java.util.Date;
14
 
13
 
15
import javax.servlet.http.HttpServletRequest;
14
import javax.servlet.http.HttpServletRequest;
16
import javax.servlet.http.HttpSession;
15
import javax.servlet.http.HttpSession;
17
 
16
 
Line 66... Line 65...
66
		
65
		
67
		int totalNumRows = 0;
66
		int totalNumRows = 0;
68
	    int successfullyProcessedNumRows = 0;
67
	    int successfullyProcessedNumRows = 0;
69
	    for (Row row : wb.getSheetAt(0)) {
68
	    for (Row row : wb.getSheetAt(0)) {
70
	    	String key = "";
69
	    	String key = "";
-
 
70
	    	String listingId = null;
-
 
71
	    	String listingName = null;
-
 
72
	    	Long price =0L;
-
 
73
	    	Long itemId = 0L;
-
 
74
	    	Double subsidy = 0.0;
-
 
75
	    	Date expiryDate = null;
71
	        try {
76
	        try {
72
	            totalNumRows++;
77
	            totalNumRows++;
73
	            if(totalNumRows==1) {
78
	            if(totalNumRows==1) {
74
	            	continue;
79
	            	continue;
75
	            }
80
	            }
76
	            long warehouseId = 0L;
81
	            long warehouseId = 0L;
-
 
82
	            try {
77
	            row.getCell(LISTING_ID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
83
		            row.getCell(LISTING_ID_INDEX).setCellType(Cell.CELL_TYPE_STRING);
78
            	String listingId = row.getCell(LISTING_ID_INDEX).getStringCellValue();
84
	            	listingId = row.getCell(LISTING_ID_INDEX).getStringCellValue();
79
            	Long itemId = new Double(row.getCell(ITEM_ID_INDEX).getNumericCellValue()).longValue();
85
	            	itemId = new Double(row.getCell(ITEM_ID_INDEX).getNumericCellValue()).longValue();
80
            	String listingName = row.getCell(LISTING_NAME_INDEX).getStringCellValue();
86
	            	listingName = row.getCell(LISTING_NAME_INDEX).getStringCellValue();
81
            	Long price = new Double(row.getCell(PRICE_INDEX).getNumericCellValue()).longValue();
87
	            	price = new Double(row.getCell(PRICE_INDEX).getNumericCellValue()).longValue();
82
            	Date expiryDate = null;
-
 
83
            	try {
-
 
84
            		//TODO Test getDateCellValue
88
	            	subsidy = row.getCell(SUBSIDY_INDEX).getNumericCellValue();
85
            		//row.getCell(EXPIRY_DATE_INDEX).setCellType(Cell.CELL_TYPE_STRING);
89
	            	Cell warehouseCell = row.getCell(DEFAULT_WAREHOUSE_INDEX);
86
            		//row.getCell(EXPIRY_DATE_INDEX).setCellType(Cell.CELL_TYPE_STRING);
90
	            	if(warehouseCell != null && warehouseCell.getCellType() != Cell.CELL_TYPE_BLANK) {
87
            		//String expiryDateString = row.getCell(EXPIRY_DATE_INDEX).getStringCellValue();
91
	            		warehouseId = new Double(row.getCell(DEFAULT_WAREHOUSE_INDEX).getNumericCellValue()).longValue();
88
            		//expiryDate = sdf.parse(expiryDateString);
92
	            	} else {
89
            	} catch (Exception e) {
93
	            		warehouseId = 0L;
90
            		logger.warn("Error in updating expiry timestamp for Ebay Listing", e);
-
 
91
            	}
94
	            	}
92
            	Double subsidy = row.getCell(SUBSIDY_INDEX).getNumericCellValue();
-
 
93
            	Cell warehouseCell = row.getCell(DEFAULT_WAREHOUSE_INDEX);
95
	            } catch (Exception e) {
94
            	if(warehouseCell != null && warehouseCell.getCellType() != Cell.CELL_TYPE_BLANK) {
96
	            	setErrorMsg(getErrorMsg() + "<br/>Error in reading input for row number " + totalNumRows);
95
            		warehouseId = new Double(row.getCell(DEFAULT_WAREHOUSE_INDEX).getNumericCellValue()).longValue();
-
 
96
            	} else {
97
	            	continue;
97
            		warehouseId = 0L;
-
 
98
            	}
98
	            }
99
            	
99
            	
100
            	CatalogService.Client catalogClient = new CatalogClient().getClient();
100
            	CatalogService.Client catalogClient = new CatalogClient().getClient();
101
            	EbayItem ebayItem = new EbayItem();
101
            	EbayItem ebayItem = new EbayItem();
102
            	ebayItem.setEbayListingId(listingId);
102
            	ebayItem.setEbayListingId(listingId);
103
            	ebayItem.setItemId(itemId);
103
            	ebayItem.setItemId(itemId);
104
            	ebayItem.setListingName(listingName);
104
            	ebayItem.setListingName(listingName);
105
            	ebayItem.setListingPrice(price);
105
            	ebayItem.setListingPrice(price);
106
            	try {
106
            	try {
-
 
107
            		//TODO Check for Date and Time sanity
107
            		ebayItem.setListingExpiryDate(interchangeDateAndMonth(row.getCell(EXPIRY_DATE_INDEX).getDateCellValue()).getTime());
108
            		ebayItem.setListingExpiryDate(interchangeDateAndMonth(row.getCell(EXPIRY_DATE_INDEX).getDateCellValue()).getTime());
108
            	} catch (Exception e) {
109
            	} catch (Exception e) {
109
            		logger.warn("Error while setting expiry time for Ebay Listing", e);
110
            		logger.warn("Error while setting expiry time for Ebay Listing", e);
110
            	}
111
            	}
111
            	ebayItem.setSubsidy(subsidy);
112
            	ebayItem.setSubsidy(subsidy);