Subversion Repositories SmartDukaan

Rev

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

Rev 11197 Rev 12449
Line 1... Line 1...
1
package in.shop2020.support.controllers;
1
package in.shop2020.support.controllers;
2
 
2
 
3
import java.io.BufferedInputStream;
3
import java.io.BufferedInputStream;
-
 
4
import java.io.BufferedReader;
4
import java.io.File;
5
import java.io.File;
5
import java.io.FileInputStream;
6
import java.io.FileInputStream;
-
 
7
import java.io.FileNotFoundException;
-
 
8
import java.io.FileReader;
6
import java.io.FileWriter;
9
import java.io.FileWriter;
7
import java.io.IOException;
10
import java.io.IOException;
8
import java.io.InputStream;
11
import java.io.InputStream;
-
 
12
import java.text.ParseException;
-
 
13
import java.util.ArrayList;
9
import java.util.Arrays;
14
import java.util.Arrays;
-
 
15
import java.util.Calendar;
-
 
16
import java.util.Date;
-
 
17
import java.util.GregorianCalendar;
10
import java.util.HashMap;
18
import java.util.HashMap;
11
import java.util.List;
19
import java.util.List;
12
import java.util.Map;
20
import java.util.Map;
13
 
21
 
14
import javax.servlet.ServletContext;
22
import javax.servlet.ServletContext;
Line 16... Line 24...
16
import javax.servlet.ServletRequest;
24
import javax.servlet.ServletRequest;
17
import javax.servlet.http.HttpServletRequest;
25
import javax.servlet.http.HttpServletRequest;
18
import javax.servlet.http.HttpServletResponse;
26
import javax.servlet.http.HttpServletResponse;
19
import javax.servlet.http.HttpSession;
27
import javax.servlet.http.HttpSession;
20
 
28
 
-
 
29
import in.shop2020.model.v1.catalog.AmazonPromotionType;
21
import in.shop2020.model.v1.catalog.Amazonlisted;
30
import in.shop2020.model.v1.catalog.Amazonlisted;
22
import in.shop2020.model.v1.catalog.CatalogServiceException;
31
import in.shop2020.model.v1.catalog.CatalogServiceException;
23
import in.shop2020.model.v1.catalog.Item;
32
import in.shop2020.model.v1.catalog.Item;
24
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
33
import in.shop2020.model.v1.inventory.AmazonFbaInventorySnapshot;
25
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
34
import in.shop2020.model.v1.inventory.AmazonInventorySnapshot;
-
 
35
import in.shop2020.model.v1.catalog.AmazonPromotion;
26
import in.shop2020.model.v1.catalog.CatalogService.Client;
36
import in.shop2020.model.v1.catalog.CatalogService.Client;
27
import in.shop2020.model.v1.inventory.InventoryServiceException;
37
import in.shop2020.model.v1.inventory.InventoryServiceException;
28
import in.shop2020.model.v1.order.AmazonOrder;
38
import in.shop2020.model.v1.order.AmazonOrder;
29
import in.shop2020.support.utils.ReportsUtils;
39
import in.shop2020.support.utils.ReportsUtils;
-
 
40
import in.shop2020.support.utils.PromotionFeed;
30
import in.shop2020.thrift.clients.CatalogClient;
41
import in.shop2020.thrift.clients.CatalogClient;
31
import in.shop2020.thrift.clients.InventoryClient;
42
import in.shop2020.thrift.clients.InventoryClient;
32
import in.shop2020.thrift.clients.LogisticsClient;
43
import in.shop2020.thrift.clients.LogisticsClient;
33
import in.shop2020.thrift.clients.TransactionClient;
44
import in.shop2020.thrift.clients.TransactionClient;
34
import in.shop2020.logistics.DeliveryType;
45
import in.shop2020.logistics.DeliveryType;
Line 51... Line 62...
51
import org.apache.thrift.TException;
62
import org.apache.thrift.TException;
52
import org.apache.thrift.transport.TTransportException;
63
import org.apache.thrift.transport.TTransportException;
53
import org.slf4j.Logger;
64
import org.slf4j.Logger;
54
import org.slf4j.LoggerFactory;
65
import org.slf4j.LoggerFactory;
55
 
66
 
-
 
67
import com.amazonaws.mws.MarketplaceWebServiceException;
-
 
68
import com.ibm.icu.text.SimpleDateFormat;
56
import com.opensymphony.xwork2.ValidationAwareSupport;
69
import com.opensymphony.xwork2.ValidationAwareSupport;
57
 
70
 
58
@SuppressWarnings("serial")
71
@SuppressWarnings("serial")
59
 
72
 
60
@InterceptorRefs({
73
@InterceptorRefs({
61
	@InterceptorRef("defaultStack"),
74
    @InterceptorRef("defaultStack"),
62
	@InterceptorRef("login")
75
    @InterceptorRef("login")
63
})
76
})
64
@Results({
77
@Results({
65
	@Result(name = "redirect", location = "${url}", type = "redirect"),
78
    @Result(name = "redirect", location = "${url}", type = "redirect"),
66
	@Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
79
    @Result(name="authsuccess", type="redirectAction", params = {"actionName" , "reports"})
67
})
80
})
68
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
81
public class AmazonListController extends ValidationAwareSupport implements ServletRequestAware ,ServletResponseAware, ServletContextAware{
69
 
82
 
70
	private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
83
    private static Logger logger = LoggerFactory.getLogger(AmazonListController.class);
71
 
84
 
72
	private HttpServletRequest request;
85
    private HttpServletRequest request;
73
	private HttpSession session;
86
    private HttpSession session;
74
	private ServletContext context;
87
    private ServletContext context;
75
	private HttpServletResponse response;
88
    private HttpServletResponse response;
76
	private String url;
89
    private String url;
77
	private String id;
90
    private String id;
78
	private String itemId;
91
    private String itemId;
79
	private String isFba;
92
    private String isFba;
80
	private String isNonFba;
93
    private String isNonFba;
81
	private String isInventoryOverride;
94
    private String isInventoryOverride;
82
	private String fbaPrice;
95
    private String fbaPrice;
83
	private String sellingPrice;
96
    private String sellingPrice;
84
	private String saholicPrice;
97
    private String saholicPrice;
85
	private String isTime;
98
    private String isTime;
86
	private String handlingTime;
99
    private String handlingTime;
87
	private String customHandlingTime;
100
    private String customHandlingTime;
88
	private String holdInventory;
101
    private String holdInventory;
89
	private String defaultInventory;
102
    private String defaultInventory;
90
	private String fileUploadFileName;
103
    private String fileUploadFileName;
91
	private String fileUploadContentType;
104
    private String fileUploadContentType;
92
	private String suppressMfnPriceUpdate;
105
    private String suppressMfnPriceUpdate;
93
	private String suppressFbaPriceUpdate;
106
    private String suppressFbaPriceUpdate;
94
	private File file;
107
    private File file;
95
	private String errMsg;
108
    private String errMsg;
96
	private String next;
109
    private String next;
97
	private List<Amazonlisted> amazonItems;
110
    private List<Amazonlisted> amazonItems;
98
	private String searchText;
111
    private String searchText;
99
	private long searchCount;
112
    private long searchCount;
100
	private long totalCount;
113
    private long totalCount;
101
	private String taxCode;
114
    private String taxCode;
102
	private String fbbTaxCode;
115
    private String fbbTaxCode;
103
	private String isFbb;
116
    private String isFbb;
104
	private String fbbPrice;
117
    private String fbbPrice;
105
	private String suppressFbbPriceUpdate;
118
    private String suppressFbbPriceUpdate;
106
 
119
    private String startDate;
107
	public String index() {
120
    private String endDate;
108
		if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
121
    private List<AmazonPromotion> promotionResult;
109
			return "authfail";
122
    private String promotionType;
110
		}
123
    private String overrrideWanlc;
111
		return "index";
124
    private String exceptionalWanlc;
112
	}
125
    private String autoDecrement;
113
 
126
    private String autoIncrement;
114
	public String fetchItems() throws TException {
127
    private String autoFavourite;
115
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
128
    private String manualFavourite;
116
		if (searchText.length() == 0) {
129
    private String otherCost;
117
			amazonItems = CatalogClient.getAmazonListedItems(Long.valueOf(next), 10);
130
    
118
			totalCount = CatalogClient.getCountForAmazonlistedItems();
131
    public String getOtherCost() {
119
			setSearchCount(totalCount);
132
        return otherCost;
120
		} else {
133
    }
121
			List<String> subString = Arrays.asList(searchText.split(" "));
134
 
122
			amazonItems = CatalogClient.searchAmazonItems(subString,Long.valueOf(next), 10);
135
    public void setOtherCost(String otherCost) {
123
			totalCount = CatalogClient.getCountForAmazonlistedItems();
136
        this.otherCost = otherCost;
124
			searchCount = CatalogClient.getAmazonSearchResultCount(subString);
137
    }
125
		}
138
 
126
		return "amazon-item-table";
139
    public String getAutoDecrement() {
127
	}
140
        return autoDecrement;
128
 
141
    }
129
 
142
 
130
	public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
143
    public void setAutoDecrement(String autoDecrement) {
131
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
144
        this.autoDecrement = autoDecrement;
132
		return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
145
    }
133
	}
146
 
134
 
147
    public String getAutoIncrement() {
135
	public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
148
        return autoIncrement;
136
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
149
    }
137
		return CatalogClient.getItem(Long.valueOf(id));
150
 
138
	}
151
    public void setAutoIncrement(String autoIncrement) {
139
 
152
        this.autoIncrement = autoIncrement;
140
 
153
    }
141
 
154
 
142
	public String update() throws NumberFormatException, TException{
155
    public String getAutoFavourite() {
143
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
156
        return autoFavourite;
144
		boolean flag=false;
157
    }
145
		boolean commit=false;
158
 
146
		long delay = Long.valueOf(customHandlingTime);
159
    public void setAutoFavourite(String autoFavourite) {
147
		if ( Boolean.valueOf(isTime)) {
160
        this.autoFavourite = autoFavourite;
148
			flag = true;
161
    }
149
		}
162
 
150
		changeItemInventory();
163
    public String getManualFavourite() {
151
		Amazonlisted amazonlisted = CatalogClient.getAmazonItemDetails(Long.valueOf(itemId));
164
        return manualFavourite;
152
		if (amazonlisted.getSellingPrice()!=Double.valueOf(sellingPrice)){
165
    }
153
			amazonlisted.setSellingPrice(Double.valueOf(sellingPrice));
166
 
154
			commit=true;
167
    public void setManualFavourite(String manualFavourite) {
155
		}
168
        this.manualFavourite = manualFavourite;
156
		if (amazonlisted.getFbaPrice()!=Double.valueOf(fbaPrice)){
169
    }
157
			amazonlisted.setFbaPrice(Double.valueOf(fbaPrice));
170
 
158
			commit=true;
171
 
159
		}
172
    public String index() {
160
		if (amazonlisted.isIsFba()!=Boolean.valueOf(isFba)){
173
        if (!ReportsUtils.canAccessReport((Long) session.getAttribute(ReportsUtils.ROLE),request.getServletPath())) {
161
			amazonlisted.setIsFba(Boolean.valueOf(isFba));
174
            return "authfail";
162
			commit=true;
175
        }
163
		}
176
        return "index";
164
		if (amazonlisted.isIsNonFba()!=Boolean.valueOf(isNonFba)){
177
    }
165
			amazonlisted.setIsNonFba(Boolean.valueOf(isNonFba));
178
 
166
			commit=true;
179
    public String fetchItems() throws TException {
167
		}
180
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
168
		if (amazonlisted.isIsCustomTime()!=flag){
181
        if (searchText.length() == 0) {
169
			amazonlisted.setIsCustomTime(flag);
182
            amazonItems = CatalogClient.getAmazonListedItems(Long.valueOf(next), 10);
170
			commit=true;
183
            totalCount = CatalogClient.getCountForAmazonlistedItems();
171
		}
184
            setSearchCount(totalCount);
172
		if (amazonlisted.getHandlingTime()!=delay){
185
        } else {
173
			amazonlisted.setHandlingTime(delay);
186
            List<String> subString = Arrays.asList(searchText.split(" "));
174
			commit=true;
187
            amazonItems = CatalogClient.searchAmazonItems(subString,Long.valueOf(next), 10);
175
		}
188
            totalCount = CatalogClient.getCountForAmazonlistedItems();
176
		if(amazonlisted.isIsInventoryOverride()!=Boolean.valueOf(isInventoryOverride)){
189
            searchCount = CatalogClient.getAmazonSearchResultCount(subString);
177
			amazonlisted.setIsInventoryOverride(Boolean.valueOf(isInventoryOverride));
190
        }
178
			commit=true;
191
        return "amazon-item-table";
179
		}
192
    }
180
		if(amazonlisted.isSuppressMfnPriceUpdate()!=Boolean.valueOf(suppressMfnPriceUpdate)){
193
 
181
			amazonlisted.setSuppressMfnPriceUpdate(Boolean.valueOf(suppressMfnPriceUpdate));
194
 
182
			commit=true;
195
    public Amazonlisted fetchItemDetail() throws NumberFormatException, TException {
183
		}
196
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
184
		if(amazonlisted.isSuppressFbaPriceUpdate()!=Boolean.valueOf(suppressFbaPriceUpdate)){
197
        return CatalogClient.getAmazonItemDetails(Long.valueOf(id));
185
			amazonlisted.setSuppressFbaPriceUpdate(Boolean.valueOf(suppressFbaPriceUpdate));
198
    }
186
			commit=true;
199
 
187
		}
200
    public Item getSaholicItem(String id) throws NumberFormatException, CatalogServiceException, TException {
188
 
201
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
189
		if(!StringUtils.equals(amazonlisted.getTaxCode(), taxCode)){
202
        return CatalogClient.getItem(Long.valueOf(id));
190
			amazonlisted.setTaxCode(taxCode);
203
    }
191
			commit=true;
204
 
192
		}
205
 
193
		
206
 
194
		if(!StringUtils.equals(amazonlisted.getFbbtaxCode(), fbbTaxCode)){
207
    public String update() throws NumberFormatException, TException{
-
 
208
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
-
 
209
        boolean flag=false;
-
 
210
        boolean commit=false;
-
 
211
        long delay = Long.valueOf(customHandlingTime);
-
 
212
        if ( Boolean.valueOf(isTime)) {
-
 
213
            flag = true;
-
 
214
        }
-
 
215
        changeItemInventory();
-
 
216
        Amazonlisted amazonlisted = CatalogClient.getAmazonItemDetails(Long.valueOf(itemId));
-
 
217
        if (amazonlisted.getSellingPrice()!=Double.valueOf(sellingPrice)){
-
 
218
            amazonlisted.setSellingPrice(Double.valueOf(sellingPrice));
-
 
219
            commit=true;
-
 
220
        }
-
 
221
        if (amazonlisted.getFbaPrice()!=Double.valueOf(fbaPrice)){
-
 
222
            amazonlisted.setFbaPrice(Double.valueOf(fbaPrice));
-
 
223
            commit=true;
-
 
224
        }
-
 
225
        if (amazonlisted.isIsFba()!=Boolean.valueOf(isFba)){
-
 
226
            amazonlisted.setIsFba(Boolean.valueOf(isFba));
-
 
227
            commit=true;
-
 
228
        }
-
 
229
        if (amazonlisted.isIsNonFba()!=Boolean.valueOf(isNonFba)){
-
 
230
            amazonlisted.setIsNonFba(Boolean.valueOf(isNonFba));
-
 
231
            commit=true;
-
 
232
        }
-
 
233
        if (amazonlisted.isIsCustomTime()!=flag){
-
 
234
            amazonlisted.setIsCustomTime(flag);
-
 
235
            commit=true;
-
 
236
        }
-
 
237
        if (amazonlisted.getHandlingTime()!=delay){
-
 
238
            amazonlisted.setHandlingTime(delay);
-
 
239
            commit=true;
-
 
240
        }
-
 
241
        if(amazonlisted.isIsInventoryOverride()!=Boolean.valueOf(isInventoryOverride)){
-
 
242
            amazonlisted.setIsInventoryOverride(Boolean.valueOf(isInventoryOverride));
-
 
243
            commit=true;
-
 
244
        }
-
 
245
        if(amazonlisted.isSuppressMfnPriceUpdate()!=Boolean.valueOf(suppressMfnPriceUpdate)){
-
 
246
            amazonlisted.setSuppressMfnPriceUpdate(Boolean.valueOf(suppressMfnPriceUpdate));
-
 
247
            commit=true;
-
 
248
        }
-
 
249
        if(amazonlisted.isSuppressFbaPriceUpdate()!=Boolean.valueOf(suppressFbaPriceUpdate)){
-
 
250
            amazonlisted.setSuppressFbaPriceUpdate(Boolean.valueOf(suppressFbaPriceUpdate));
-
 
251
            commit=true;
-
 
252
        }
-
 
253
 
-
 
254
        if(!StringUtils.equals(amazonlisted.getTaxCode(), taxCode)){
-
 
255
            amazonlisted.setTaxCode(taxCode);
-
 
256
            commit=true;
-
 
257
        }
-
 
258
 
-
 
259
        if(!StringUtils.equals(amazonlisted.getFbbtaxCode(), fbbTaxCode)){
195
            amazonlisted.setFbbtaxCode(fbbTaxCode);
260
            amazonlisted.setFbbtaxCode(fbbTaxCode);
196
            commit=true;
261
            commit=true;
197
        }
262
        }
198
		
263
 
199
		if(amazonlisted.isSuppressFbbPriceUpdate()!=Boolean.valueOf(suppressFbbPriceUpdate)){
264
        if(amazonlisted.isSuppressFbbPriceUpdate()!=Boolean.valueOf(suppressFbbPriceUpdate)){
200
            amazonlisted.setSuppressFbbPriceUpdate(Boolean.valueOf(suppressFbbPriceUpdate));
265
            amazonlisted.setSuppressFbbPriceUpdate(Boolean.valueOf(suppressFbbPriceUpdate));
201
            commit=true;
266
            commit=true;
202
        }
267
        }
203
		
268
 
204
		if (amazonlisted.getFbbPrice()!=Double.valueOf(fbbPrice)){
269
        if (amazonlisted.getFbbPrice()!=Double.valueOf(fbbPrice)){
205
            amazonlisted.setFbbPrice(Double.valueOf(fbbPrice));
270
            amazonlisted.setFbbPrice(Double.valueOf(fbbPrice));
206
            commit=true;
271
            commit=true;
207
        }
272
        }
-
 
273
 
208
		if (amazonlisted.isIsFbb()!=Boolean.valueOf(isFbb)){
274
        if (amazonlisted.isIsFbb()!=Boolean.valueOf(isFbb)){
209
            amazonlisted.setIsFbb(Boolean.valueOf(isFbb));
275
            amazonlisted.setIsFbb(Boolean.valueOf(isFbb));
210
            commit=true;
276
            commit=true;
211
        }
277
        }
212
 
278
 
213
		if(commit){
279
        if (amazonlisted.isAutoDecrement()!=Boolean.valueOf(autoDecrement)){
214
			CatalogClient.updateAmazonItemDetails(amazonlisted);
280
            amazonlisted.setAutoDecrement(Boolean.valueOf(autoDecrement));
215
		}
281
            commit=true;
216
		else{
282
        }
217
			logger.info("Nothing new to commit");
283
        
218
		}
284
        if (amazonlisted.isAutoIncrement()!=Boolean.valueOf(autoIncrement)){
219
		return "index";
285
            amazonlisted.setAutoIncrement(Boolean.valueOf(autoIncrement));
220
 
286
            commit=true;
221
	}
287
        }
222
 
288
        
223
	public void upload() throws IOException, TException {
289
        if (amazonlisted.isAutoFavourite()!=Boolean.valueOf(autoFavourite)){
224
		File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
290
            amazonlisted.setAutoFavourite(Boolean.valueOf(autoFavourite));
225
		FileUtils.copyFile(this.file, fileToCreate);
291
            commit=true;
226
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
292
        }
227
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
293
        
228
		HSSFSheet sheet = workbook.getSheetAt(0);
294
        if (amazonlisted.isManualFavourite()!=Boolean.valueOf(manualFavourite)){
229
		Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
295
            amazonlisted.setManualFavourite(Boolean.valueOf(manualFavourite));
230
		for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
296
            commit=true;
231
			TransactionClient tcl = new TransactionClient();
297
        }
232
			List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
298
 
233
			for (AmazonOrder order : orders){
299
 
234
				if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
300
        if (amazonlisted.isOverrrideWanlc()!=Boolean.valueOf(overrrideWanlc)){
235
					Map<String,String> dateMap = new HashMap<String,String>();
301
            amazonlisted.setOverrrideWanlc(Boolean.valueOf(overrrideWanlc));
236
					dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
302
            commit=true;
237
					amazonOrderMap.put(order.getOrderId(), dateMap);
303
        }
238
				}
304
 
239
			}
305
        if (amazonlisted.getExceptionalWanlc()!=Double.valueOf(exceptionalWanlc)){
240
		}
306
            amazonlisted.setExceptionalWanlc(Double.valueOf(exceptionalWanlc));
241
		TransactionClient tcl = new TransactionClient();
307
            commit=true;
242
		tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
308
        }
243
	}
309
        
244
 
310
        if (amazonlisted.getOtherCost()!=Double.valueOf(otherCost)){
245
 
311
            amazonlisted.setOtherCost(Double.valueOf(otherCost));
246
 
312
            commit=true;
247
	private void changeItemInventory() throws NumberFormatException, TException {
313
        }
248
		Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
314
 
249
 
315
        if(commit){
250
		if (StringUtils.isEmpty(holdInventory)) {
316
            CatalogClient.updateAmazonItemDetails(amazonlisted);
251
			holdInventory = "0";
317
        }
252
		}
318
        else{
253
		if (StringUtils.isEmpty(defaultInventory)) {
319
            logger.info("Nothing new to commit");
254
			defaultInventory = "0";
320
        }
255
		}
321
        return "index";
256
		CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
322
 
257
	}
323
    }
258
 
324
 
259
 
325
    public void upload() throws IOException, TException {
260
	public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
326
        File fileToCreate = new File("/tmp/", "Amazon-shipping.xls");
261
		InventoryClient inventoryServiceClient = new InventoryClient();
327
        FileUtils.copyFile(this.file, fileToCreate);
262
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
328
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
263
		in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
329
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
264
		return thriftItemInventory.getAvailability();
330
        HSSFSheet sheet = workbook.getSheetAt(0);
265
 
331
        Map<Long,Map<String,String>> amazonOrderMap = new HashMap<Long,Map<String,String>>();
266
	}
332
        for (int iterator=sheet.getFirstRowNum();iterator<=sheet.getLastRowNum();iterator++){
267
 
333
            TransactionClient tcl = new TransactionClient();
268
	public Map<Long, Long> getReservedItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
334
            List<AmazonOrder> orders = tcl.getClient().getAmazonOrderByAmazonOrderId(sheet.getRow(iterator).getCell(0).getStringCellValue());
269
		InventoryClient inventoryServiceClient = new InventoryClient();
335
            for (AmazonOrder order : orders){
270
		in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
336
                if (StringUtils.equals(order.getStatus(), "Order-Payment-Success")){
271
		in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
337
                    Map<String,String> dateMap = new HashMap<String,String>();
272
		return thriftItemInventory.getReserved();
338
                    dateMap.put(sheet.getRow(iterator).getCell(1).getStringCellValue(), sheet.getRow(iterator).getCell(2).getStringCellValue());
273
 
339
                    amazonOrderMap.put(order.getOrderId(), dateMap);
274
	}
340
                }
275
 
341
            }
276
	public String getWarehouseName(String warehouseId) throws NumberFormatException, TException { 
342
        }
277
		InventoryClient inventoryServiceClient = new InventoryClient();
343
        TransactionClient tcl = new TransactionClient();
278
		return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
344
        tcl.getClient().updateTimestampForAmazonOrder(amazonOrderMap);
279
	}
345
    }
280
 
346
 
281
	public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
347
    public void uploadPromotionSheet() throws IOException, ParseException, TException, CatalogServiceException{
282
		InventoryClient inventoryServiceClient = new InventoryClient();
348
        Map<String,AmazonPromotion> amazonPromoMap = new HashMap<String,AmazonPromotion>();
283
		try { 
349
        SimpleDateFormat dateFormatter;
284
			return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
350
        if (promotionType.equalsIgnoreCase("SHORTTERM")){
285
		}
351
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
286
		catch (Exception e){
352
        }
287
			return null;
353
        else{
288
		}
354
            dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
289
	}
355
        }
290
 
356
        File fileToCreate = new File("/tmp/", "Amazon-Promotion-"+String.valueOf(getTimeInMilliseconds())+".xls");
291
	public List<AmazonFbaInventorySnapshot> getFbaInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
357
        FileUtils.copyFile(this.file, fileToCreate);
292
		InventoryClient inventoryServiceClient = new InventoryClient();
358
        BufferedReader reader = null;
293
		try { 
359
        try {
294
			return inventoryServiceClient.getClient().getAmazonFbaItemInventory(Long.valueOf(itemId));
360
            reader = new BufferedReader(new FileReader(file.getAbsolutePath()));
295
		}
361
        } catch (FileNotFoundException e1) {
296
		catch (Exception e){
362
            // TODO Auto-generated catch block
297
			return null;
363
            e1.printStackTrace();
298
		}
364
        }
299
	}
365
        String str;
300
 
366
        int lineNumber = 0;
301
	public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
367
        while ((str = reader.readLine()) != null) {
302
		LogisticsClient logisticsClient = new LogisticsClient();
368
            lineNumber++;
303
		return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
369
            if (str.trim().length() == 0 || lineNumber<4) {
304
 
370
                continue;
305
	}
371
            }
306
 
372
 
307
	public String runAsinJob() throws IOException, InterruptedException {
373
            String[] values = str.split("\t");
308
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
374
            AmazonPromotion amazonPromotion = new AmazonPromotion();
309
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
375
            amazonPromotion.setSku(values[0]);
310
			return "authfail";
376
            amazonPromotion.setStandardPrice(Double.valueOf(values[11]));
311
		}
377
            amazonPromotion.setSalePrice(Double.valueOf(values[17]));
312
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
378
            Date startDate = dateFormatter.parse(values[18]);
313
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunAsinJob.sh"};
379
            Date endDate = dateFormatter.parse(values[19]);
314
		testProcess.command(command);
380
            amazonPromotion.setStartDate(startDate.getTime());
315
		logger.info(testProcess.command().toString());
381
            amazonPromotion.setEndDate(endDate.getTime());
316
		Process process = testProcess.start();
382
            amazonPromotion.setPromotionActive(true);
317
		process.waitFor();
383
            amazonPromotion.setPromotionType(AmazonPromotionType.valueOf(promotionType));
318
		logger.info(String.valueOf(process.exitValue()));
384
            amazonPromoMap.put(amazonPromotion.getSku(), amazonPromotion);
319
		return "asinjob";
385
        }
320
 
386
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
321
	}
387
        if (!cc.addAmazonPromotion(amazonPromoMap)){
322
	
388
            throw new CatalogServiceException();
323
	public String runFbbListingJob() throws IOException, InterruptedException {
389
        }
-
 
390
//        if (promotionType.equalsIgnoreCase("LONGTERM")){
-
 
391
//            PromotionFeed pm = new PromotionFeed();
-
 
392
//            List<AmazonPromotion> list = new ArrayList<AmazonPromotion>(amazonPromoMap.values());
-
 
393
//            String fPath = pm.CreatePromotionFeed(list);
-
 
394
//            try {
-
 
395
//                logger.info(fPath);
-
 
396
//                pm.SubmitPromotionFeed(fPath);
-
 
397
//            } catch (InterruptedException e) {
-
 
398
//                // TODO Auto-generated catch block
-
 
399
//                e.printStackTrace();
-
 
400
//            } catch (MarketplaceWebServiceException e) {
-
 
401
//                // TODO Auto-generated catch block
-
 
402
//                e.printStackTrace();
-
 
403
//            }
-
 
404
//        }
-
 
405
    }
-
 
406
 
-
 
407
 
-
 
408
 
-
 
409
    private void changeItemInventory() throws NumberFormatException, TException {
-
 
410
        Client CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
-
 
411
 
-
 
412
        if (StringUtils.isEmpty(holdInventory)) {
-
 
413
            holdInventory = "0";
-
 
414
        }
-
 
415
        if (StringUtils.isEmpty(defaultInventory)) {
-
 
416
            defaultInventory = "0";
-
 
417
        }
-
 
418
        CatalogClient.updateItemInventory(Long.valueOf(itemId),Long.valueOf(holdInventory),Long.valueOf(defaultInventory));
-
 
419
    }
-
 
420
 
-
 
421
 
-
 
422
    public Map<Long, Long> getAvailableItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
-
 
423
        InventoryClient inventoryServiceClient = new InventoryClient();
-
 
424
        in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
425
        in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
-
 
426
        return thriftItemInventory.getAvailability();
-
 
427
 
-
 
428
    }
-
 
429
 
-
 
430
    public Map<Long, Long> getReservedItemInventory(String itemId) throws NumberFormatException, InventoryServiceException, TException{
-
 
431
        InventoryClient inventoryServiceClient = new InventoryClient();
-
 
432
        in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
-
 
433
        in.shop2020.model.v1.inventory.ItemInventory thriftItemInventory = inventoryClient.getItemInventoryByItemId(Long.valueOf(itemId));
-
 
434
        return thriftItemInventory.getReserved();
-
 
435
 
-
 
436
    }
-
 
437
 
-
 
438
    public String getWarehouseName(String warehouseId) throws NumberFormatException, TException { 
-
 
439
        InventoryClient inventoryServiceClient = new InventoryClient();
-
 
440
        return inventoryServiceClient.getClient().getWarehouseName(Long.valueOf(warehouseId));
-
 
441
    }
-
 
442
 
-
 
443
    public AmazonInventorySnapshot getInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
-
 
444
        InventoryClient inventoryServiceClient = new InventoryClient();
-
 
445
        try { 
-
 
446
            return inventoryServiceClient.getClient().getAmazonInventoryForItem(Long.valueOf(itemId));
-
 
447
        }
-
 
448
        catch (Exception e){
-
 
449
            return null;
-
 
450
        }
-
 
451
    }
-
 
452
 
-
 
453
    public List<AmazonFbaInventorySnapshot> getFbaInventoryForAmazonItem(String itemId) throws NumberFormatException, TException {
-
 
454
        InventoryClient inventoryServiceClient = new InventoryClient();
-
 
455
        try { 
-
 
456
            return inventoryServiceClient.getClient().getAmazonFbaItemInventory(Long.valueOf(itemId));
-
 
457
        }
-
 
458
        catch (Exception e){
-
 
459
            return null;
-
 
460
        }
-
 
461
    }
-
 
462
 
-
 
463
//    public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
-
 
464
//        LogisticsClient logisticsClient = new LogisticsClient();
-
 
465
//        return logisticsClient.getClient().getLogisticsInfo("110001", Long.valueOf(itemId), DeliveryType.COD, PickUpType.COURIER).getShippingTime();
-
 
466
//    }
-
 
467
    
-
 
468
      public Long getTimetoShip(String itemId) throws LogisticsServiceException, TException{
-
 
469
          return 0l;
-
 
470
    }
-
 
471
    
-
 
472
    
-
 
473
    public double getWanlcForItem(String itemId){
-
 
474
        InventoryClient inventoryServiceClient;
-
 
475
        try {
-
 
476
            inventoryServiceClient = new InventoryClient();
-
 
477
        } catch (TTransportException e1) {
-
 
478
            // TODO Auto-generated catch block
-
 
479
            return 0.0;
-
 
480
        }
-
 
481
        try { 
-
 
482
            return inventoryServiceClient.getClient().getWanNlcForSource(Long.valueOf(itemId), 3);
-
 
483
        }
-
 
484
        catch (Exception e){
-
 
485
            return 0.0;
-
 
486
        }
-
 
487
    }
-
 
488
 
-
 
489
    public long getTimeInMilliseconds(){
-
 
490
        Calendar cal=GregorianCalendar.getInstance();
-
 
491
        return cal.getTimeInMillis();
-
 
492
    }
-
 
493
 
-
 
494
    public String runAsinJob() throws IOException, InterruptedException {
-
 
495
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
-
 
496
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
-
 
497
            return "authfail";
-
 
498
        }
-
 
499
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
-
 
500
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunAsinJob.sh"};
-
 
501
        testProcess.command(command);
-
 
502
        logger.info(testProcess.command().toString());
-
 
503
        Process process = testProcess.start();
-
 
504
        process.waitFor();
-
 
505
        logger.info(String.valueOf(process.exitValue()));
-
 
506
        return "asinjob";
-
 
507
 
-
 
508
    }
-
 
509
 
-
 
510
    public String runFbbListingJob() throws IOException, InterruptedException {
324
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
511
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
325
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
512
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
326
            return "authfail";
513
            return "authfail";
327
        }
514
        }
328
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
515
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
Line 332... Line 519...
332
        Process process = testProcess.start();
519
        Process process = testProcess.start();
333
        process.waitFor();
520
        process.waitFor();
334
        logger.info(String.valueOf(process.exitValue()));
521
        logger.info(String.valueOf(process.exitValue()));
335
        return "asinjob";
522
        return "asinjob";
336
    }
523
    }
337
	
-
 
338
 
524
 
339
	public String runFbaListingJob() throws IOException, InterruptedException {
525
 
340
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
526
    public String runFbaListingJob() throws IOException, InterruptedException {
341
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
527
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
342
			return "authfail";
528
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
343
		}
529
            return "authfail";
344
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
530
        }
345
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbaListingJob.sh"};
531
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
346
		testProcess.command(command);
532
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunFbaListingJob.sh"};
347
		logger.info(testProcess.command().toString());
533
        testProcess.command(command);
348
		Process process = testProcess.start();
534
        logger.info(testProcess.command().toString());
349
		process.waitFor();
535
        Process process = testProcess.start();
350
		logger.info(String.valueOf(process.exitValue()));
536
        process.waitFor();
351
		return "asinjob";
537
        logger.info(String.valueOf(process.exitValue()));
352
	}
538
        return "asinjob";
353
 
539
    }
354
	public String runNonFbaListingJob() throws IOException, InterruptedException {
540
 
355
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
541
    public String runNonFbaListingJob() throws IOException, InterruptedException {
356
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
542
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
357
			return "authfail";
543
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
358
		}
544
            return "authfail";
359
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
545
        }
360
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunNonFbaListingJob.sh"};
546
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
361
		testProcess.command(command);
547
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/RunNonFbaListingJob.sh"};
362
		logger.info(testProcess.command().toString());
548
        testProcess.command(command);
363
		Process process = testProcess.start();
549
        logger.info(testProcess.command().toString());
364
		process.waitFor();
550
        Process process = testProcess.start();
365
		logger.info(String.valueOf(process.exitValue()));
551
        process.waitFor();
366
		return "asinjob";
552
        logger.info(String.valueOf(process.exitValue()));
367
	}
553
        return "asinjob";
368
	
554
    }
369
	public void runFbaInventoryJob() throws IOException, InterruptedException {
555
 
370
		ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
556
    public void runFbaInventoryJob() throws IOException, InterruptedException {
371
		String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/SubmitFBAInventoryFeed.sh"};
557
        ProcessBuilder testProcess = new ProcessBuilder("/bin/bash");
372
		testProcess.command(command);
558
        String[] command = {"/bin/bash", "-c", "sudo /root/code/trunk/AmazonFeeds/SubmitFBAInventoryFeed.sh"};
373
		logger.info(testProcess.command().toString());
559
        testProcess.command(command);
374
		Process process = testProcess.start();
560
        logger.info(testProcess.command().toString());
375
		process.waitFor();
561
        Process process = testProcess.start();
376
		logger.info(String.valueOf(process.exitValue()));
562
        process.waitFor();
377
	}
563
        logger.info(String.valueOf(process.exitValue()));
378
 
564
    }
379
	public void uploadAsinFile() throws IOException, TException{
565
 
380
		File fileToCreate = new File("/tmp/", "Amazon-asin-upload.xls");
566
    public void uploadAsinFile() throws IOException, TException{
381
		FileUtils.copyFile(this.file, fileToCreate);
567
        File fileToCreate = new File("/tmp/", "Amazon-asin-upload.xls");
382
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
568
        FileUtils.copyFile(this.file, fileToCreate);
383
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
569
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
384
		HSSFSheet sheet = workbook.getSheetAt(0);
570
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
385
		Map<Long,Item> amazonAsin = new HashMap<Long,Item>();
571
        HSSFSheet sheet = workbook.getSheetAt(0);
386
		StringBuilder sb =new StringBuilder();
572
        Map<Long,Item> amazonAsin = new HashMap<Long,Item>();
387
		Client CatalogClient=null;
573
        StringBuilder sb =new StringBuilder();
388
		try {
574
        Client CatalogClient=null;
389
			CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
575
        try {
390
		} catch (TTransportException e) {
576
            CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
391
			e.printStackTrace();
577
        } catch (TTransportException e) {
392
		}
578
            e.printStackTrace();
393
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
579
        }
394
			Item item=null;
580
        for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
395
			Long sku;
581
            Item item=null;
396
			String asin;
582
            Long sku;
397
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
583
            String asin;
398
				continue;
584
            if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
399
			}
585
                continue;
400
			else {
586
            }
401
				sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
587
            else {
402
				try {
588
                sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
403
					item = CatalogClient.getItem(sku);
589
                try {
404
				} catch (Exception e) {
590
                    item = CatalogClient.getItem(sku);
405
					logger.info("Unable to fetch item details ID= "+sku);
591
                } catch (Exception e) {
406
					logger.info("Unable to fetch item. "+e);
592
                    logger.info("Unable to fetch item details ID= "+sku);
407
					sb.append("Service exception ItemId not updated Id= "+sku+"\n");
593
                    logger.info("Unable to fetch item. "+e);
408
					continue;
594
                    sb.append("Service exception ItemId not updated Id= "+sku+"\n");
409
				} 
595
                    continue;
410
			}
596
                } 
411
 
597
            }
412
			if(item.getId() == 0){
598
 
413
				logger.info("Item Id doesn't exist in catalog Id= "+sku);
599
            if(item.getId() == 0){
414
				sb.append("Item Id doesn't exist in catalog Id= "+sku+"\n");
600
                logger.info("Item Id doesn't exist in catalog Id= "+sku);
415
				continue;
601
                sb.append("Item Id doesn't exist in catalog Id= "+sku+"\n");
416
			}
602
                continue;
417
 
603
            }
418
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
604
 
419
				asin = sheet.getRow(iterator).getCell(1).getStringCellValue();
605
            if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
420
				item.setAsin(asin);
606
                asin = sheet.getRow(iterator).getCell(1).getStringCellValue();
421
			}
607
                item.setAsin(asin);
422
 
608
            }
423
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
609
 
424
				long virtualInventory =(long) sheet.getRow(iterator).getCell(2).getNumericCellValue();
610
            if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
425
				item.setDefaultInventory(virtualInventory);
611
                long virtualInventory =(long) sheet.getRow(iterator).getCell(2).getNumericCellValue();
426
			}
612
                item.setDefaultInventory(virtualInventory);
427
 
613
            }
428
			if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
614
 
429
				long riskyInventory =(long) sheet.getRow(iterator).getCell(3).getNumericCellValue();
615
            if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
430
				item.setHoldInventory(riskyInventory);
616
                long riskyInventory =(long) sheet.getRow(iterator).getCell(3).getNumericCellValue();
431
			}
617
                item.setHoldInventory(riskyInventory);
432
 
618
            }
433
			amazonAsin.put(sku, item);
619
 
434
		}
620
            amazonAsin.put(sku, item);
435
		CatalogClient.updateAsin(amazonAsin);
621
        }
436
		
622
        CatalogClient.updateAsin(amazonAsin);
437
		logger.info("Amazon Asin Map "+amazonAsin.toString());
623
 
438
		CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
624
        logger.info("Amazon Asin Map "+amazonAsin.toString());
439
		CatalogClient.updateAsin(amazonAsin);
625
        CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
440
		File file = new File("/tmp/asinfile");
626
        CatalogClient.updateAsin(amazonAsin);
441
		FileWriter writer = new FileWriter(file);
627
        File file = new File("/tmp/asinfile");
442
		writer.append(sb.toString());
628
        FileWriter writer = new FileWriter(file);
443
		writer.close();
629
        writer.append(sb.toString());
444
		byte[] buffer = new byte[(int)file.length()];
630
        writer.close();
445
		InputStream input = null;
631
        byte[] buffer = new byte[(int)file.length()];
446
		try {
632
        InputStream input = null;
447
			int totalBytesRead = 0;
633
        try {
448
			input = new BufferedInputStream(new FileInputStream(file));
634
            int totalBytesRead = 0;
449
			while(totalBytesRead < buffer.length){
635
            input = new BufferedInputStream(new FileInputStream(file));
450
				int bytesRemaining = buffer.length - totalBytesRead;
636
            while(totalBytesRead < buffer.length){
451
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
637
                int bytesRemaining = buffer.length - totalBytesRead;
452
				if (bytesRead > 0){
638
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
453
					totalBytesRead = totalBytesRead + bytesRead;
639
                if (bytesRead > 0){
454
				}
640
                    totalBytesRead = totalBytesRead + bytesRead;
455
			}
641
                }
456
		}
642
            }
457
		finally {
643
        }
458
			input.close();
644
        finally {
459
			file.delete();
645
            input.close();
460
		}
646
            file.delete();
461
 
647
        }
462
		response.setHeader("Content-Type", "text/javascript");
648
 
463
 
649
        response.setHeader("Content-Type", "text/javascript");
464
		ServletOutputStream sos;
650
 
465
		try {
651
        ServletOutputStream sos;
466
			sos = response.getOutputStream();
652
        try {
467
			sos.write(buffer);
653
            sos = response.getOutputStream();
468
			sos.flush();
654
            sos.write(buffer);
469
		} catch (IOException e) {
655
            sos.flush();
470
			System.out.println("Unable to stream the manifest file");
656
        } catch (IOException e) {
471
		}   
657
            System.out.println("Unable to stream the manifest file");
472
	}
658
        }   
473
 
659
    }
474
	public void uploadBulkFile() throws IOException, TException{
660
 
475
		File fileToCreate = new File("/tmp/", "Amazon-bulk-upload.xls");
661
    public void uploadBulkFile() throws IOException, TException{
476
		FileUtils.copyFile(this.file, fileToCreate);
662
        File fileToCreate = new File("/tmp/", "Amazon-bulk-upload.xls");
477
		FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
663
        FileUtils.copyFile(this.file, fileToCreate);
478
		HSSFWorkbook workbook = new HSSFWorkbook(iFile);
664
        FileInputStream iFile = new FileInputStream(new File(file.getAbsolutePath()));
479
		
665
        HSSFWorkbook workbook = new HSSFWorkbook(iFile);
480
		HSSFSheet sheet = workbook.getSheetAt(0);
666
 
481
		Map<Long,Amazonlisted> amazonBulkUpdate = new HashMap<Long,Amazonlisted>();
667
        HSSFSheet sheet = workbook.getSheetAt(0);
482
		Client CatalogClient=null;
668
        Map<Long,Amazonlisted> amazonBulkUpdate = new HashMap<Long,Amazonlisted>();
483
		StringBuilder sb = new StringBuilder();
669
        Client CatalogClient=null;
484
		try {
670
        StringBuilder sb = new StringBuilder();
485
			CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
671
        try {
486
		} catch (TTransportException e) {
672
            CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
487
			// TODO Auto-generated catch block
673
        } catch (TTransportException e) {
488
			e.printStackTrace();
674
            // TODO Auto-generated catch block
489
		}
675
            e.printStackTrace();
490
		for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
676
        }
491
			Amazonlisted amazonlisted =null;
677
        for (int iterator=(sheet.getFirstRowNum()+1);iterator<=sheet.getLastRowNum();iterator++){
492
			Long sku;
678
            Amazonlisted amazonlisted =null;
493
			if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
679
            Long sku;
494
				continue;
680
            if (checkEmptyString(sheet.getRow(iterator).getCell(0))){
495
			}
681
                continue;
496
			else {
682
            }
497
				sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
683
            else {
498
				try {
684
                sku=(long) sheet.getRow(iterator).getCell(0).getNumericCellValue();
499
					amazonlisted = CatalogClient.getAmazonItemDetails(sku);
685
                try {
500
				} catch (TException e) {
686
                    amazonlisted = CatalogClient.getAmazonItemDetails(sku);
501
					logger.info("Unable to fetch item details ID= "+sku);
687
                } catch (TException e) {
502
					sb.append("Service exception ItemId not updated Id= "+sku+"\n");
688
                    logger.info("Unable to fetch item details ID= "+sku);
503
					continue;
689
                    sb.append("Service exception ItemId not updated Id= "+sku+"\n");
504
				}
690
                    continue;
505
			}
691
                }
506
 
692
            }
507
			if(amazonlisted.getItemid() == 0){
693
 
508
				logger.info("Item Id doesn't exist in amazonlisted Id= "+sku);
694
            if(amazonlisted.getItemid() == 0){
509
				sb.append("Item Id doesn't exist in amazonlisted Id= "+sku+"\n");
695
                logger.info("Item Id doesn't exist in amazonlisted Id= "+sku);
510
				continue;
696
                sb.append("Item Id doesn't exist in amazonlisted Id= "+sku+"\n");
511
			}
697
                continue;
512
 
698
            }
513
			if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
699
 
514
				double mfnPrice = sheet.getRow(iterator).getCell(1).getNumericCellValue();
700
            if (!checkEmptyString(sheet.getRow(iterator).getCell(1))){
515
				amazonlisted.setSellingPrice(mfnPrice);
701
                double mfnPrice = sheet.getRow(iterator).getCell(1).getNumericCellValue();
516
			}
702
                amazonlisted.setSellingPrice(mfnPrice);
517
 
703
            }
518
			if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
704
 
519
				double fbaSellingPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
705
            if (!checkEmptyString(sheet.getRow(iterator).getCell(2))){
520
				amazonlisted.setFbaPrice(fbaSellingPrice);
706
                double fbaSellingPrice = sheet.getRow(iterator).getCell(2).getNumericCellValue();
521
			}
707
                amazonlisted.setFbaPrice(fbaSellingPrice);
522
			
708
            }
523
			if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
709
 
-
 
710
            if (!checkEmptyString(sheet.getRow(iterator).getCell(3))){
524
                double fbbSellingPrice = sheet.getRow(iterator).getCell(3).getNumericCellValue();
711
                double fbbSellingPrice = sheet.getRow(iterator).getCell(3).getNumericCellValue();
525
                amazonlisted.setFbbPrice(fbbSellingPrice);
712
                amazonlisted.setFbbPrice(fbbSellingPrice);
526
            }
713
            }
527
 
714
 
528
			if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
715
            if (!checkEmptyString(sheet.getRow(iterator).getCell(4))){
529
				if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==1){
716
                if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==1){
530
					amazonlisted.setIsNonFba(true);
717
                    amazonlisted.setIsNonFba(true);
531
				}
718
                }
532
				if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==0){
719
                if ((long)sheet.getRow(iterator).getCell(4).getNumericCellValue()==0){
533
					amazonlisted.setIsNonFba(false);
720
                    amazonlisted.setIsNonFba(false);
534
				}
721
                }
535
			}
722
            }
536
 
723
 
537
			if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
724
            if (!checkEmptyString(sheet.getRow(iterator).getCell(5))){
538
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
725
                if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==1){
539
					amazonlisted.setIsFba(true);
726
                    amazonlisted.setIsFba(true);
540
				}
727
                }
541
				if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
728
                if ((long)sheet.getRow(iterator).getCell(5).getNumericCellValue()==0){
542
					amazonlisted.setIsFba(false);
729
                    amazonlisted.setIsFba(false);
543
				}
730
                }
544
			}
731
            }
545
			
732
 
546
			if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
733
            if (!checkEmptyString(sheet.getRow(iterator).getCell(6))){
547
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
734
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==1){
548
                    amazonlisted.setIsFbb(true);
735
                    amazonlisted.setIsFbb(true);
549
                }
736
                }
550
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
737
                if ((long)sheet.getRow(iterator).getCell(6).getNumericCellValue()==0){
551
                    amazonlisted.setIsFbb(false);
738
                    amazonlisted.setIsFbb(false);
552
                }
739
                }
553
            }
740
            }
554
			
741
 
555
			if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
742
            if (!checkEmptyString(sheet.getRow(iterator).getCell(7))){
556
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
743
                if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==1){
557
					amazonlisted.setIsInventoryOverride(true);
744
                    amazonlisted.setIsInventoryOverride(true);
558
				}
745
                }
559
				if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
746
                if ((long)sheet.getRow(iterator).getCell(7).getNumericCellValue()==0){
560
					amazonlisted.setIsInventoryOverride(false);
747
                    amazonlisted.setIsInventoryOverride(false);
561
				}
748
                }
562
			}
749
            }
563
			if (!checkEmptyString(sheet.getRow(iterator).getCell(8))){
750
            if (!checkEmptyString(sheet.getRow(iterator).getCell(8))){
564
				if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==1){
751
                if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==1){
565
					amazonlisted.setSuppressMfnPriceUpdate(true);
752
                    amazonlisted.setSuppressMfnPriceUpdate(true);
566
				}
753
                }
567
				if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==0){
754
                if ((long)sheet.getRow(iterator).getCell(8).getNumericCellValue()==0){
568
					amazonlisted.setSuppressMfnPriceUpdate(false);
755
                    amazonlisted.setSuppressMfnPriceUpdate(false);
569
				}
756
                }
570
			}
757
            }
571
 
758
 
572
			if (!checkEmptyString(sheet.getRow(iterator).getCell(9))){
759
            if (!checkEmptyString(sheet.getRow(iterator).getCell(9))){
573
				if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==1){
760
                if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==1){
574
					amazonlisted.setSuppressFbaPriceUpdate(true);
761
                    amazonlisted.setSuppressFbaPriceUpdate(true);
575
				}
762
                }
576
				if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==0){
763
                if ((long)sheet.getRow(iterator).getCell(9).getNumericCellValue()==0){
577
					amazonlisted.setSuppressFbaPriceUpdate(false);
764
                    amazonlisted.setSuppressFbaPriceUpdate(false);
578
				}
765
                }
579
			}
766
            }
580
			
767
 
581
			if (!checkEmptyString(sheet.getRow(iterator).getCell(10))){
768
            if (!checkEmptyString(sheet.getRow(iterator).getCell(10))){
582
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==1){
769
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==1){
583
                    amazonlisted.setSuppressFbbPriceUpdate(true);
770
                    amazonlisted.setSuppressFbbPriceUpdate(true);
584
                }
771
                }
585
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==0){
772
                if ((long)sheet.getRow(iterator).getCell(10).getNumericCellValue()==0){
586
                    amazonlisted.setSuppressFbbPriceUpdate(false);
773
                    amazonlisted.setSuppressFbbPriceUpdate(false);
587
                }
774
                }
588
            }
775
            }
589
 
776
 
590
			if (!checkEmptyString(sheet.getRow(iterator).getCell(11))){
777
            if (!checkEmptyString(sheet.getRow(iterator).getCell(11))){
591
				String taxCode = sheet.getRow(iterator).getCell(11).getStringCellValue();
778
                String taxCode = sheet.getRow(iterator).getCell(11).getStringCellValue();
592
				amazonlisted.setTaxCode(taxCode);
779
                amazonlisted.setTaxCode(taxCode);
593
			}
780
            }
594
			
781
 
595
			if (!checkEmptyString(sheet.getRow(iterator).getCell(12))){
782
            if (!checkEmptyString(sheet.getRow(iterator).getCell(12))){
596
                String fbbTaxCode = sheet.getRow(iterator).getCell(12).getStringCellValue();
783
                String fbbTaxCode = sheet.getRow(iterator).getCell(12).getStringCellValue();
597
                amazonlisted.setFbbtaxCode(fbbTaxCode);
784
                amazonlisted.setFbbtaxCode(fbbTaxCode);
598
            }
785
            }
599
			
786
 
600
			amazonBulkUpdate.put(sku, amazonlisted);
787
            amazonBulkUpdate.put(sku, amazonlisted);
601
		}
788
        }
602
		logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
789
        logger.info("Amazon Bulk Map "+amazonBulkUpdate.toString());
603
		CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
790
        CatalogClient = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
604
		boolean result = CatalogClient.updateAmazonAttributesInBulk(amazonBulkUpdate);
791
        boolean result = CatalogClient.updateAmazonAttributesInBulk(amazonBulkUpdate);
605
		if (!result){
792
        if (!result){
606
			sb = new StringBuilder();
793
            sb = new StringBuilder();
607
			sb.append("Error : Unable to update");
794
            sb.append("Error : Unable to update");
608
		}
795
        }
609
		File file = new File("/tmp/amazonbulk");
796
        File file = new File("/tmp/amazonbulk");
610
		FileWriter writer = new FileWriter(file);
797
        FileWriter writer = new FileWriter(file);
611
		writer.append(sb.toString());
798
        writer.append(sb.toString());
612
		writer.close();
799
        writer.close();
613
		byte[] buffer = new byte[(int)file.length()];
800
        byte[] buffer = new byte[(int)file.length()];
614
		InputStream input = null;
801
        InputStream input = null;
615
		try {
802
        try {
616
			int totalBytesRead = 0;
803
            int totalBytesRead = 0;
617
			input = new BufferedInputStream(new FileInputStream(file));
804
            input = new BufferedInputStream(new FileInputStream(file));
618
			while(totalBytesRead < buffer.length){
805
            while(totalBytesRead < buffer.length){
619
				int bytesRemaining = buffer.length - totalBytesRead;
806
                int bytesRemaining = buffer.length - totalBytesRead;
620
				int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
807
                int bytesRead = input.read(buffer, totalBytesRead, bytesRemaining); 
621
				if (bytesRead > 0){
808
                if (bytesRead > 0){
622
					totalBytesRead = totalBytesRead + bytesRead;
809
                    totalBytesRead = totalBytesRead + bytesRead;
623
				}
810
                }
624
			}
811
            }
625
		}
812
        }
626
		finally {
813
        finally {
627
			input.close();
814
            input.close();
628
			file.delete();
815
            file.delete();
629
		}
816
        }
630
 
817
 
631
		response.setHeader("Content-Type", "text/javascript");
818
        response.setHeader("Content-Type", "text/javascript");
632
 
819
 
633
		ServletOutputStream sos;
820
        ServletOutputStream sos;
634
		try {
821
        try {
635
			sos = response.getOutputStream();
822
            sos = response.getOutputStream();
636
			sos.write(buffer);
823
            sos.write(buffer);
637
			sos.flush();
824
            sos.flush();
638
		} catch (IOException e) {
825
        } catch (IOException e) {
639
			System.out.println("Unable to stream the manifest file");
826
            System.out.println("Unable to stream the manifest file");
640
		}   
827
        }   
641
	}
828
    }
642
 
829
 
643
 
830
 
644
 
831
 
645
 
832
 
646
	public boolean checkEmptyString(Cell cell){
833
    public boolean checkEmptyString(Cell cell){
647
		if (cell==null){
834
        if (cell==null){
648
			return true;
835
            return true;
649
		}
836
        }
650
		return false;
837
        return false;
651
	}
838
    }
652
 
839
 
653
	public String uploadSheet(){
840
    public String uploadSheet(){
654
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
841
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
655
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
842
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
656
			return "authfail";
843
            return "authfail";
657
		}
844
        }
658
		return "amazon-shipping-upload";
845
        return "amazon-shipping-upload";
659
	}
846
    }
660
 
847
 
661
	public String uploadAsin(){
848
    public String uploadPromotion(){
662
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
849
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
663
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
850
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
664
			return "authfail";
851
            return "authfail";
665
		}
852
        }
666
		return "amazon-asin-upload";
853
        return "amazon-promotion-upload";
667
	}
854
    }
668
 
855
 
669
	public String uploadBulkSheet(){
856
    public String uploadAsin(){
670
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
857
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
671
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
858
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
672
			return "authfail";
859
            return "authfail";
673
		}
860
        }
674
		return "amazon-bulk-upload";
861
        return "amazon-asin-upload";
675
	}
862
    }
676
 
863
 
677
 
864
    public String uploadBulkSheet(){
678
	public String edit() {
865
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0])) {
679
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
866
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1].split("!")[0]);
680
			return "authfail";
867
            return "authfail";
681
		}
868
        }
682
		return "edit";
869
        return "amazon-bulk-upload";
683
	}
870
    }
684
 
871
 
685
	public String show() {
872
 
686
		if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
873
    public String edit() {
687
			logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
874
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
688
			return "authfail";
875
            return "authfail";
689
		}
876
        }
690
 
877
        return "edit";
691
		if (StringUtils.equals(id, "options")){
878
    }
692
			return "options";
879
 
693
		}
880
    public String viewPromotionDetails() throws ParseException, TException{
694
 
881
        logger.info(startDate);
695
		if (StringUtils.equals(id, "item-table")){
882
        logger.info(endDate);
696
			return "amazon-item-table";
883
        SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
697
		}
884
        Date start = dateFormatter.parse(startDate);
698
 
885
        Date end = dateFormatter.parse(endDate);
699
		return "id";
886
        logger.info(start.getTime()+"");
700
	}
887
        logger.info(end.getTime()+"");
701
 
888
        Client cc = new CatalogClient("catalog_service_server_host_amazon","catalog_service_server_port").getClient();
702
	public String editNew() {
889
        setPromotionResult(cc.getAmazonPromotion(start.getTime(),end.getTime()));
703
		return "editNew";
890
        return "amazon-promotion-result";
704
	}	
891
    }
705
 
892
 
706
	public void setId(String id) {
893
    public String getDate(long timestamp){
707
		logger.info(id);
894
        return new java.util.Date(timestamp).toLocaleString();
708
		this.id = id;
895
    }
709
	}
896
 
710
 
897
    public String show() {
711
	public void setUrl(String url) {
898
        if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getRequestURI().substring(request.getContextPath().length()).split("/")[1])) {
712
		this.url = url;
899
            logger.info(request.getRequestURI().substring(request.getContextPath().length()).split("/")[1]);
713
	}
900
            return "authfail";
714
 
901
        }
715
	public String getUrl() {
902
 
716
		return url;
903
        if (StringUtils.equals(id, "options")){
717
	}
904
            return "options";
718
 
905
        }
719
	public String getId() {
906
 
720
		return id;
907
        if (StringUtils.equals(id, "item-table")){
721
	}
908
            return "amazon-item-table";
722
 
909
        }
723
	public void setItemId(String itemId) {
910
 
724
		this.itemId = itemId;
911
        if (StringUtils.equals(id, "promotion")){
725
	}
912
            return "amazon-promotion";
726
 
913
        }
727
	public String getItemId() {
914
 
728
		return itemId;
915
        return "id";
729
	}
916
    }
730
 
917
 
731
	public void setIsFba(String isFba) {
918
    public String editNew() {
732
		this.isFba = isFba;
919
        return "editNew";
733
	}
920
    }	
734
 
921
 
735
	public String getIsFba() {
922
    public void setId(String id) {
736
		return isFba;
923
        logger.info(id);
737
	}
924
        this.id = id;
738
 
925
    }
739
	public void setIsNonFba(String isNonFba) {
926
 
740
		this.isNonFba = isNonFba;
927
    public void setUrl(String url) {
741
	}
928
        this.url = url;
742
 
929
    }
743
	public String getIsNonFba() {
930
 
744
		return isNonFba;
931
    public String getUrl() {
745
	}
932
        return url;
746
 
933
    }
747
	public void setIsInventoryOverride(String isInventoryOverride) {
934
 
748
		this.isInventoryOverride = isInventoryOverride;
935
    public String getId() {
749
	}
936
        return id;
750
 
937
    }
751
	public String getIsInventoryOverride() {
938
 
752
		return isInventoryOverride;
939
    public void setItemId(String itemId) {
753
	}
940
        this.itemId = itemId;
754
 
941
    }
755
	public void setSellingPrice(String sellingPrice) {
942
 
756
		this.sellingPrice = sellingPrice;
943
    public String getItemId() {
757
	}
944
        return itemId;
758
 
945
    }
759
	public String getSellingPrice() {
946
 
760
		return sellingPrice;
947
    public void setIsFba(String isFba) {
761
	}
948
        this.isFba = isFba;
762
 
949
    }
763
	public void setFbaPrice(String fbaPrice) {
950
 
764
		this.fbaPrice = fbaPrice;
951
    public String getIsFba() {
765
	}
952
        return isFba;
766
 
953
    }
767
	public String getFbaPrice() {
954
 
768
		return fbaPrice;
955
    public void setIsNonFba(String isNonFba) {
769
	}
956
        this.isNonFba = isNonFba;
770
 
957
    }
771
	public void setSaholicPrice(String saholicPrice) {
958
 
772
		this.saholicPrice = saholicPrice;
959
    public String getIsNonFba() {
773
	}
960
        return isNonFba;
774
 
961
    }
775
	public String getSaholicPrice() {
962
 
776
		return saholicPrice;
963
    public void setIsInventoryOverride(String isInventoryOverride) {
777
	}
964
        this.isInventoryOverride = isInventoryOverride;
778
 
965
    }
779
	public void setIsTime(String isTime){
966
 
780
		logger.info("set istime"+isTime);
967
    public String getIsInventoryOverride() {
781
		this.isTime = isTime;
968
        return isInventoryOverride;
782
	}
969
    }
783
 
970
 
784
	public String getIsTime(){
971
    public void setSellingPrice(String sellingPrice) {
785
		return isTime;
972
        this.sellingPrice = sellingPrice;
786
	}
973
    }
787
 
974
 
788
	public void setHandlingTime(String handlingTime){
975
    public String getSellingPrice() {
789
		this.handlingTime = handlingTime;
976
        return sellingPrice;
790
	}
977
    }
791
 
978
 
792
	public String getHandlingTime(){
979
    public void setFbaPrice(String fbaPrice) {
793
		return handlingTime;
980
        this.fbaPrice = fbaPrice;
794
	}
981
    }
795
 
982
 
796
	public void setCustomHandlingTime(String customHandlingTime){
983
    public String getFbaPrice() {
797
		logger.info("set custom handling time"+customHandlingTime);
984
        return fbaPrice;
798
		this.customHandlingTime = customHandlingTime;
985
    }
799
	}
986
 
800
 
987
    public void setSaholicPrice(String saholicPrice) {
801
	public String getCustomHandlingTime(){
988
        this.saholicPrice = saholicPrice;
802
		return customHandlingTime;
989
    }
803
	}
990
 
804
 
991
    public String getSaholicPrice() {
805
	public void setHoldInventory(String holdInventory){
992
        return saholicPrice;
806
		this.holdInventory = holdInventory;
993
    }
807
	}
994
 
808
 
995
    public void setIsTime(String isTime){
809
	public String getHoldInventory(){
996
        logger.info("set istime"+isTime);
810
		return holdInventory;
997
        this.isTime = isTime;
811
	}
998
    }
812
 
999
 
813
	public void setDefaultInventory(String defaultInventory){
1000
    public String getIsTime(){
814
		this.defaultInventory = defaultInventory;
1001
        return isTime;
815
	}
1002
    }
816
 
1003
 
817
	public String getDefaultInventory(){
1004
    public void setHandlingTime(String handlingTime){
818
		return defaultInventory;
1005
        this.handlingTime = handlingTime;
819
	}
1006
    }
820
 
1007
 
821
	public File getFile() {
1008
    public String getHandlingTime(){
822
		return file;
1009
        return handlingTime;
823
	}
1010
    }
824
 
1011
 
825
	public void setFile(File file) {
1012
    public void setCustomHandlingTime(String customHandlingTime){
826
		this.file = file;
1013
        logger.info("set custom handling time"+customHandlingTime);
827
	}
1014
        this.customHandlingTime = customHandlingTime;
828
 
1015
    }
829
	public String getFileUploadContentType() {
1016
 
830
		return fileUploadContentType;
1017
    public String getCustomHandlingTime(){
831
	}
1018
        return customHandlingTime;
832
 
1019
    }
833
	public void setFileUploadContentType(String fileUploadContentType) {
1020
 
834
		this.fileUploadContentType = fileUploadContentType;
1021
    public void setHoldInventory(String holdInventory){
835
	}
1022
        this.holdInventory = holdInventory;
836
 
1023
    }
837
	public String getFileUploadFileName() {
1024
 
838
		return fileUploadFileName;
1025
    public String getHoldInventory(){
839
	}
1026
        return holdInventory;
840
 
1027
    }
841
	public void setFileUploadFileName(String fileUploadFileName) {
1028
 
842
		this.fileUploadFileName = fileUploadFileName;
1029
    public void setDefaultInventory(String defaultInventory){
843
	}
1030
        this.defaultInventory = defaultInventory;
844
 
1031
    }
845
	public void setServletRequest(HttpServletRequest req) {
1032
 
846
		this.request = req;
1033
    public String getDefaultInventory(){
847
		this.session = req.getSession();        
1034
        return defaultInventory;
848
	}
1035
    }
849
 
1036
 
850
	@Override
1037
    public File getFile() {
851
	public void setServletContext(ServletContext arg0) {
1038
        return file;
852
		// TODO Auto-generated method stub
1039
    }
853
 
1040
 
854
	}
1041
    public void setFile(File file) {
855
 
1042
        this.file = file;
856
 
1043
    }
857
	public void setSuppressMfnPriceUpdate(String suppressMfnPriceUpdate) {
1044
 
858
		this.suppressMfnPriceUpdate = suppressMfnPriceUpdate;
1045
    public String getFileUploadContentType() {
859
	}
1046
        return fileUploadContentType;
860
 
1047
    }
861
	public String getSuppressMfnPriceUpdate() {
1048
 
862
		return suppressMfnPriceUpdate;
1049
    public void setFileUploadContentType(String fileUploadContentType) {
863
	}
1050
        this.fileUploadContentType = fileUploadContentType;
864
 
1051
    }
865
	public void setSuppressFbaPriceUpdate(String suppressFbaPriceUpdate) {
1052
 
866
		this.suppressFbaPriceUpdate = suppressFbaPriceUpdate;
1053
    public String getFileUploadFileName() {
867
	}
1054
        return fileUploadFileName;
868
 
1055
    }
869
	public String getSuppressFbaPriceUpdate() {
1056
 
870
		return suppressFbaPriceUpdate;
1057
    public void setFileUploadFileName(String fileUploadFileName) {
871
	}
1058
        this.fileUploadFileName = fileUploadFileName;
872
 
1059
    }
873
	public void setErrMsg(String errMsg) {
1060
 
874
		this.errMsg = errMsg;
1061
    public void setServletRequest(HttpServletRequest req) {
875
	}
1062
        this.request = req;
876
 
1063
        this.session = req.getSession();        
877
	public String getErrMsg() {
1064
    }
878
		return errMsg;
1065
 
879
	}
1066
    @Override
880
 
1067
    public void setServletContext(ServletContext arg0) {
881
	public void setServletResponse(HttpServletResponse response) {
1068
        // TODO Auto-generated method stub
882
		this.response = response;
1069
 
883
	}
1070
    }
884
 
1071
 
885
	public void setNext(String next) {
1072
 
886
		logger.info("next is"+next);
1073
    public void setSuppressMfnPriceUpdate(String suppressMfnPriceUpdate) {
887
		this.next = next;
1074
        this.suppressMfnPriceUpdate = suppressMfnPriceUpdate;
888
	}
1075
    }
889
 
1076
 
890
	public String getNext() {
1077
    public String getSuppressMfnPriceUpdate() {
891
		return next;
1078
        return suppressMfnPriceUpdate;
892
	}
1079
    }
893
 
1080
 
894
	public void setAmazonItems(List<Amazonlisted> amazonItems) {
1081
    public void setSuppressFbaPriceUpdate(String suppressFbaPriceUpdate) {
895
		this.amazonItems = amazonItems;
1082
        this.suppressFbaPriceUpdate = suppressFbaPriceUpdate;
896
	}
1083
    }
897
 
1084
 
898
	public List<Amazonlisted> getAmazonItems() {
1085
    public String getSuppressFbaPriceUpdate() {
899
		return amazonItems;
1086
        return suppressFbaPriceUpdate;
900
	}
1087
    }
901
 
1088
 
902
	public void setSearchText(String searchText) {
1089
    public void setErrMsg(String errMsg) {
903
		this.searchText = searchText;
1090
        this.errMsg = errMsg;
904
	}
1091
    }
905
 
1092
 
906
	public String getSearchText() {
1093
    public String getErrMsg() {
907
		return searchText;
1094
        return errMsg;
908
	}
1095
    }
909
 
1096
 
910
	public long getSearchCount() {
1097
    public void setServletResponse(HttpServletResponse response) {
911
		return searchCount;
1098
        this.response = response;
912
	}
1099
    }
913
 
1100
 
914
	public long getTotalCount() {
1101
    public void setNext(String next) {
915
		return totalCount;
1102
        logger.info("next is"+next);
916
	}
1103
        this.next = next;
917
 
1104
    }
918
	public void setSearchCount(long count) {
1105
 
919
		this.searchCount = count;
1106
    public String getNext() {
920
	}
1107
        return next;
921
 
1108
    }
922
	public void setTaxCode(String taxCode) {
1109
 
923
		this.taxCode = taxCode;
1110
    public void setAmazonItems(List<Amazonlisted> amazonItems) {
924
	}
1111
        this.amazonItems = amazonItems;
925
 
1112
    }
926
	public String getTaxCode() {
1113
 
927
		return taxCode;
1114
    public List<Amazonlisted> getAmazonItems() {
928
	}
1115
        return amazonItems;
-
 
1116
    }
-
 
1117
 
-
 
1118
    public void setSearchText(String searchText) {
-
 
1119
        this.searchText = searchText;
-
 
1120
    }
-
 
1121
 
-
 
1122
    public String getSearchText() {
-
 
1123
        return searchText;
-
 
1124
    }
-
 
1125
 
-
 
1126
    public long getSearchCount() {
-
 
1127
        return searchCount;
-
 
1128
    }
-
 
1129
 
-
 
1130
    public long getTotalCount() {
-
 
1131
        return totalCount;
-
 
1132
    }
-
 
1133
 
-
 
1134
    public void setSearchCount(long count) {
-
 
1135
        this.searchCount = count;
-
 
1136
    }
-
 
1137
 
-
 
1138
    public void setTaxCode(String taxCode) {
-
 
1139
        this.taxCode = taxCode;
-
 
1140
    }
-
 
1141
 
-
 
1142
    public String getTaxCode() {
-
 
1143
        return taxCode;
-
 
1144
    }
929
 
1145
 
930
    public void setFbbTaxCode(String fbbTaxCode) {
1146
    public void setFbbTaxCode(String fbbTaxCode) {
931
        this.fbbTaxCode = fbbTaxCode;
1147
        this.fbbTaxCode = fbbTaxCode;
932
    }
1148
    }
933
 
1149
 
Line 957... Line 1173...
957
 
1173
 
958
    public String getSuppressFbbPriceUpdate() {
1174
    public String getSuppressFbbPriceUpdate() {
959
        return suppressFbbPriceUpdate;
1175
        return suppressFbbPriceUpdate;
960
    }
1176
    }
961
 
1177
 
-
 
1178
    public String getStartDate() {
-
 
1179
        return startDate;
-
 
1180
    }
-
 
1181
 
-
 
1182
    public void setStartDate(String startDate) {
-
 
1183
        this.startDate = startDate;
-
 
1184
    }
-
 
1185
 
-
 
1186
    public String getEndDate() {
-
 
1187
        return endDate;
-
 
1188
    }
-
 
1189
 
-
 
1190
    public void setEndDate(String endDate) {
-
 
1191
        this.endDate = endDate;
-
 
1192
    }
-
 
1193
 
-
 
1194
    public void setPromotionResult(List<AmazonPromotion> promotionResult) {
-
 
1195
        this.promotionResult = promotionResult;
-
 
1196
    }
-
 
1197
 
-
 
1198
    public List<AmazonPromotion> getPromotionResult() {
-
 
1199
        return promotionResult;
-
 
1200
    }
-
 
1201
 
-
 
1202
    public String getPromotionType() {
-
 
1203
        return promotionType;
-
 
1204
    }
-
 
1205
 
-
 
1206
    public void setPromotionType(String promotionType) {
-
 
1207
        this.promotionType = promotionType;
-
 
1208
    }
-
 
1209
 
-
 
1210
    public String getOverrrideWanlc() {
-
 
1211
        return overrrideWanlc;
-
 
1212
    }
-
 
1213
 
-
 
1214
    public void setOverrrideWanlc(String overrrideWanlc) {
-
 
1215
        this.overrrideWanlc = overrrideWanlc;
-
 
1216
    }
-
 
1217
 
-
 
1218
    public String getExceptionalWanlc() {
-
 
1219
        return exceptionalWanlc;
-
 
1220
    }
-
 
1221
 
-
 
1222
    public void setExceptionalWanlc(String exceptionalWanlc) {
-
 
1223
        this.exceptionalWanlc = exceptionalWanlc;
-
 
1224
    }
-
 
1225
 
962
}
1226
}