| 1494 |
vikas |
1 |
package in.shop2020.support.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
4 |
import in.shop2020.model.v1.order.Order;
|
|
|
5 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
6 |
import in.shop2020.model.v1.order.Transaction;
|
|
|
7 |
import in.shop2020.model.v1.order.TransactionServiceException;
|
|
|
8 |
import in.shop2020.model.v1.order.TransactionStatus;
|
|
|
9 |
import in.shop2020.model.v1.user.Address;
|
|
|
10 |
import in.shop2020.model.v1.user.User;
|
|
|
11 |
import in.shop2020.model.v1.user.UserContextService.Client;
|
|
|
12 |
import in.shop2020.payments.Payment;
|
|
|
13 |
import in.shop2020.payments.PaymentService;
|
|
|
14 |
import in.shop2020.payments.PaymentStatus;
|
|
|
15 |
import in.shop2020.thrift.clients.PaymentServiceClient;
|
|
|
16 |
import in.shop2020.thrift.clients.TransactionServiceClient;
|
|
|
17 |
import in.shop2020.thrift.clients.UserContextServiceClient;
|
|
|
18 |
|
|
|
19 |
import java.io.BufferedReader;
|
|
|
20 |
import java.io.ByteArrayOutputStream;
|
|
|
21 |
import java.io.IOException;
|
|
|
22 |
import java.io.UnsupportedEncodingException;
|
|
|
23 |
import java.security.Principal;
|
|
|
24 |
import java.text.DateFormat;
|
|
|
25 |
import java.text.ParseException;
|
|
|
26 |
import java.text.SimpleDateFormat;
|
|
|
27 |
import java.util.ArrayList;
|
|
|
28 |
import java.util.Date;
|
|
|
29 |
import java.util.Enumeration;
|
|
|
30 |
import java.util.List;
|
|
|
31 |
import java.util.Locale;
|
|
|
32 |
import java.util.Map;
|
|
|
33 |
|
|
|
34 |
import javax.servlet.RequestDispatcher;
|
|
|
35 |
import javax.servlet.ServletInputStream;
|
|
|
36 |
import javax.servlet.ServletOutputStream;
|
|
|
37 |
import javax.servlet.http.Cookie;
|
|
|
38 |
import javax.servlet.http.HttpServletRequest;
|
|
|
39 |
import javax.servlet.http.HttpServletResponse;
|
|
|
40 |
import javax.servlet.http.HttpSession;
|
|
|
41 |
|
|
|
42 |
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
43 |
import org.apache.poi.ss.usermodel.Cell;
|
|
|
44 |
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
45 |
import org.apache.poi.ss.usermodel.Font;
|
|
|
46 |
import org.apache.poi.ss.usermodel.Row;
|
|
|
47 |
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
48 |
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
49 |
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
50 |
import org.apache.struts2.interceptor.ServletRequestAware;
|
|
|
51 |
import org.apache.struts2.interceptor.ServletResponseAware;
|
|
|
52 |
|
|
|
53 |
public class UserOrdersController implements ServletResponseAware, ServletRequestAware{
|
|
|
54 |
|
|
|
55 |
private HttpServletRequest request;
|
|
|
56 |
private HttpServletResponse response;
|
|
|
57 |
|
|
|
58 |
private String errorMsg = "";
|
|
|
59 |
|
|
|
60 |
public UserOrdersController(){
|
|
|
61 |
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
@Override
|
|
|
65 |
public void setServletRequest(HttpServletRequest req) {
|
|
|
66 |
this.request = req;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
@Override
|
|
|
70 |
public void setServletResponse(HttpServletResponse res) {
|
|
|
71 |
this.response = res;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public String index() {
|
|
|
75 |
return "report";
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public String show(){
|
|
|
79 |
return "report";
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
// Handles the POST request (Form Submission)
|
|
|
83 |
public String create(){
|
|
|
84 |
try {
|
|
|
85 |
//Formatting Form input parameters
|
|
|
86 |
String email = request.getParameter("email");
|
|
|
87 |
String orderid = request.getParameter("orderid");
|
|
|
88 |
|
|
|
89 |
TransactionServiceClient transactionServiceClient = new TransactionServiceClient();
|
|
|
90 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = transactionServiceClient.getClient();
|
|
|
91 |
|
|
|
92 |
UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
|
|
|
93 |
Client userClient = userContextServiceClient.getClient();
|
|
|
94 |
|
|
|
95 |
PaymentServiceClient paymentServiceClient = new PaymentServiceClient();
|
|
|
96 |
in.shop2020.payments.PaymentService.Client paymentClient = paymentServiceClient.getClient();
|
|
|
97 |
|
|
|
98 |
User user = null;
|
|
|
99 |
if (email != null && !email.isEmpty()) {
|
|
|
100 |
user = userClient.getUserByEmail(email);
|
|
|
101 |
if(user.getUserId() == -1){
|
|
|
102 |
errorMsg = "No user for this id.";
|
|
|
103 |
return "report";
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
else {
|
|
|
107 |
user = userClient.getUserById(transactionClient.getOrder(Long.parseLong(orderid)).getCustomer_id());
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
if (user == null) {
|
|
|
111 |
errorMsg = "Could not find user.";
|
|
|
112 |
return "report";
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
List <Transaction> transactions = new ArrayList<Transaction>();
|
|
|
116 |
|
|
|
117 |
//Retrieving all the transactions
|
|
|
118 |
transactions.addAll(transactionClient.getTransactionsForCustomer(user.getUserId(), 0, (new Date()).getTime(), null));
|
|
|
119 |
System.out.println("Total number of Transaction: " + transactions.size());
|
|
|
120 |
|
|
|
121 |
List <Payment> payments = new ArrayList<Payment>();
|
|
|
122 |
//Retrieving all the payments
|
|
|
123 |
payments.addAll(paymentClient.getPaymentsForUser(user.getUserId(), 0,
|
|
|
124 |
(new Date()).getTime(), null, 0));
|
|
|
125 |
// Preparing XLS file for output
|
|
|
126 |
response.setContentType("application/vnd.ms-excel");
|
|
|
127 |
|
|
|
128 |
response.setHeader("Content-disposition", "inline; filename=user-orders" + ".xls");
|
|
|
129 |
|
|
|
130 |
ServletOutputStream sos;
|
|
|
131 |
try {
|
|
|
132 |
ByteArrayOutputStream baos = getSpreadSheetData(user, transactions, payments);
|
|
|
133 |
sos = response.getOutputStream();
|
|
|
134 |
baos.writeTo(sos);
|
|
|
135 |
sos.flush();
|
|
|
136 |
} catch (IOException e) {
|
|
|
137 |
errorMsg = "Failed to write to response.";
|
|
|
138 |
e.printStackTrace();
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
} catch (ParseException e) {
|
|
|
142 |
errorMsg = "Parse Exception.";
|
|
|
143 |
e.printStackTrace();
|
|
|
144 |
} catch (TransactionServiceException e) {
|
|
|
145 |
errorMsg = "Transaction Service Exception.";
|
|
|
146 |
e.printStackTrace();
|
|
|
147 |
} catch (Exception e) {
|
|
|
148 |
errorMsg = "Something went wrong.";
|
|
|
149 |
e.printStackTrace();
|
|
|
150 |
}
|
|
|
151 |
return "report";
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
// Prepares the XLS worksheet object and fills in the data with proper formatting
|
|
|
155 |
private ByteArrayOutputStream getSpreadSheetData(User user, List<Transaction> transactions, List<Payment> payments) {
|
|
|
156 |
ByteArrayOutputStream baosXLS = new ByteArrayOutputStream();
|
|
|
157 |
|
|
|
158 |
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
|
|
159 |
|
|
|
160 |
Workbook wb = new HSSFWorkbook();
|
|
|
161 |
|
|
|
162 |
Font font = wb.createFont();
|
|
|
163 |
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
164 |
CellStyle style = wb.createCellStyle();
|
|
|
165 |
style.setFont(font);
|
|
|
166 |
|
|
|
167 |
createUserSheet(user, wb, style);
|
|
|
168 |
createTransactionSheet(transactions, wb, style, dateFormat);
|
|
|
169 |
createPaymentSheet(payments, wb, style, dateFormat);
|
|
|
170 |
|
|
|
171 |
// Write the workbook to the output stream
|
|
|
172 |
try {
|
|
|
173 |
wb.write(baosXLS);
|
|
|
174 |
baosXLS.close();
|
|
|
175 |
} catch (IOException e) {
|
|
|
176 |
e.printStackTrace();
|
|
|
177 |
}
|
|
|
178 |
return baosXLS;
|
|
|
179 |
}
|
|
|
180 |
|
|
|
181 |
private void createPaymentSheet(List<Payment> payments, Workbook wb,
|
|
|
182 |
CellStyle style, DateFormat dateFormat)
|
|
|
183 |
{
|
|
|
184 |
// PAYMENT SHEET
|
|
|
185 |
Sheet paymentSheet = wb.createSheet("Payment");
|
|
|
186 |
short paymentSerialNo = 0;
|
|
|
187 |
|
|
|
188 |
Row orderTitleRow = paymentSheet.createRow(paymentSerialNo ++);
|
|
|
189 |
Cell orderTitleCell = orderTitleRow.createCell(0);
|
|
|
190 |
orderTitleCell.setCellValue("User Payments");
|
|
|
191 |
orderTitleCell.setCellStyle(style);
|
|
|
192 |
|
|
|
193 |
paymentSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
|
|
194 |
|
|
|
195 |
paymentSheet.createRow(paymentSerialNo ++);
|
|
|
196 |
|
|
|
197 |
Row orderHeaderRow = paymentSheet.createRow(paymentSerialNo ++);
|
|
|
198 |
orderHeaderRow.createCell(0).setCellValue("Transaction Id");
|
|
|
199 |
orderHeaderRow.createCell(1).setCellValue("Payment Id");
|
|
|
200 |
orderHeaderRow.createCell(2).setCellValue("Payment Status");
|
|
|
201 |
orderHeaderRow.createCell(3).setCellValue("Gateway Payment Id");
|
|
|
202 |
orderHeaderRow.createCell(4).setCellValue("Gateway Transaction Date");
|
|
|
203 |
orderHeaderRow.createCell(5).setCellValue("Gateway Txn Id");
|
|
|
204 |
orderHeaderRow.createCell(6).setCellValue("Gateway Txn Status");
|
|
|
205 |
orderHeaderRow.createCell(7).setCellValue("Reference Code");
|
|
|
206 |
orderHeaderRow.createCell(8).setCellValue("Gateway Id");
|
|
|
207 |
orderHeaderRow.createCell(9).setCellValue("Amount");
|
|
|
208 |
orderHeaderRow.createCell(10).setCellValue("Description");
|
|
|
209 |
orderHeaderRow.createCell(11).setCellValue("Auth Code");
|
|
|
210 |
orderHeaderRow.createCell(12).setCellValue("Error Code");
|
|
|
211 |
|
|
|
212 |
for (Payment payment : payments) {
|
|
|
213 |
paymentSerialNo++;
|
|
|
214 |
Row contentRow = paymentSheet.createRow(paymentSerialNo);
|
|
|
215 |
|
|
|
216 |
contentRow.createCell(0).setCellValue(payment.getMerchantTxnId());
|
|
|
217 |
contentRow.createCell(1).setCellValue(payment.getPaymentId());
|
|
|
218 |
contentRow.createCell(2).setCellValue(payment.getStatus().name());
|
|
|
219 |
contentRow.createCell(3)
|
|
|
220 |
.setCellValue(payment.getGatewayPaymentId());
|
|
|
221 |
contentRow.createCell(4).setCellValue(payment.getGatewayTxnDate());
|
|
|
222 |
contentRow.createCell(5).setCellValue(payment.getGatewayTxnId());
|
|
|
223 |
contentRow.createCell(6)
|
|
|
224 |
.setCellValue(payment.getGatewayTxnStatus());
|
|
|
225 |
contentRow.createCell(7).setCellValue(payment.getReferenceCode());
|
|
|
226 |
contentRow.createCell(8).setCellValue(payment.getGatewayId());
|
|
|
227 |
contentRow.createCell(9).setCellValue(payment.getAmount());
|
|
|
228 |
contentRow.createCell(10).setCellValue(payment.getDescription());
|
|
|
229 |
contentRow.createCell(11).setCellValue(payment.getAuthCode());
|
|
|
230 |
contentRow.createCell(12).setCellValue(payment.getErrorCode());
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
private void createTransactionSheet(List<Transaction> transactions, Workbook wb, CellStyle style, DateFormat dateFormat) {
|
|
|
235 |
// TRANSACTION SHEET
|
|
|
236 |
Sheet transactionSheet = wb.createSheet("Transaction");
|
|
|
237 |
short transactionSerialNo = 0;
|
|
|
238 |
|
|
|
239 |
Row orderTitleRow = transactionSheet.createRow(transactionSerialNo ++);
|
|
|
240 |
Cell orderTitleCell = orderTitleRow.createCell(0);
|
|
|
241 |
orderTitleCell.setCellValue("User Transactions");
|
|
|
242 |
orderTitleCell.setCellStyle(style);
|
|
|
243 |
|
|
|
244 |
transactionSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
|
|
245 |
|
|
|
246 |
transactionSheet.createRow(transactionSerialNo ++);
|
|
|
247 |
|
|
|
248 |
Row orderHeaderRow = transactionSheet.createRow(transactionSerialNo ++);
|
|
|
249 |
orderHeaderRow.createCell(0).setCellValue("Transaction Id");
|
|
|
250 |
orderHeaderRow.createCell(1).setCellValue("Transaction Date");
|
|
|
251 |
orderHeaderRow.createCell(2).setCellValue("Transaction Status");
|
|
|
252 |
orderHeaderRow.createCell(3).setCellValue("Order Id");
|
|
|
253 |
orderHeaderRow.createCell(4).setCellValue("Billing Number");
|
|
|
254 |
orderHeaderRow.createCell(5).setCellValue("Billing Date");
|
|
|
255 |
orderHeaderRow.createCell(6).setCellValue("Order Status");
|
|
|
256 |
orderHeaderRow.createCell(7).setCellValue("Brand");
|
|
|
257 |
orderHeaderRow.createCell(8).setCellValue("Model Name");
|
|
|
258 |
orderHeaderRow.createCell(9).setCellValue("Model Number");
|
|
|
259 |
orderHeaderRow.createCell(10).setCellValue("Color");
|
|
|
260 |
orderHeaderRow.createCell(11).setCellValue("Quantity");
|
|
|
261 |
orderHeaderRow.createCell(12).setCellValue("Unit Price");
|
|
|
262 |
orderHeaderRow.createCell(13).setCellValue("Total Price");
|
|
|
263 |
orderHeaderRow.createCell(14).setCellValue("User Id");
|
|
|
264 |
orderHeaderRow.createCell(15).setCellValue("Name");
|
|
|
265 |
orderHeaderRow.createCell(16).setCellValue("Address1");
|
|
|
266 |
orderHeaderRow.createCell(17).setCellValue("Address2");
|
|
|
267 |
orderHeaderRow.createCell(17).setCellValue("City");
|
|
|
268 |
orderHeaderRow.createCell(19).setCellValue("State");
|
|
|
269 |
orderHeaderRow.createCell(20).setCellValue("Pin Code");
|
|
|
270 |
orderHeaderRow.createCell(21).setCellValue("Mobile Number");
|
|
|
271 |
orderHeaderRow.createCell(22).setCellValue("email");
|
|
|
272 |
orderHeaderRow.createCell(23).setCellValue("Airway Bill No.");
|
|
|
273 |
orderHeaderRow.createCell(24).setCellValue("Billed By");
|
|
|
274 |
orderHeaderRow.createCell(25).setCellValue("Receiver");
|
|
|
275 |
orderHeaderRow.createCell(26).setCellValue("Tracking Id");
|
|
|
276 |
orderHeaderRow.createCell(27).setCellValue("Accepted Timestamp");
|
|
|
277 |
orderHeaderRow.createCell(28).setCellValue("Delivery Timestamp");
|
|
|
278 |
orderHeaderRow.createCell(29).setCellValue("Expected Delivery Time");
|
|
|
279 |
|
|
|
280 |
for(Transaction transaction : transactions) {
|
|
|
281 |
List<Order> orders = transaction.getOrders();
|
|
|
282 |
Date transactionDate = new Date(transaction.getCreatedOn());
|
|
|
283 |
long transactionId = transaction.getId();
|
|
|
284 |
String transactionStatus = transaction.getStatusDescription();
|
|
|
285 |
for(Order order : orders) {
|
|
|
286 |
transactionSerialNo ++;
|
|
|
287 |
Row contentRow = transactionSheet.createRow(transactionSerialNo);
|
|
|
288 |
LineItem lineItem = order.getLineitems().get(0);
|
|
|
289 |
|
|
|
290 |
contentRow.createCell(0).setCellValue(transactionId);
|
|
|
291 |
contentRow.createCell(1).setCellValue(dateFormat.format(transactionDate));
|
|
|
292 |
contentRow.createCell(2).setCellValue(transactionStatus);
|
|
|
293 |
contentRow.createCell(3).setCellValue(order.getId());
|
|
|
294 |
contentRow.createCell(4).setCellValue(order.getInvoice_number());
|
|
|
295 |
contentRow.createCell(5).setCellValue(dateFormat.format(new Date(order.getBilling_timestamp())));
|
|
|
296 |
contentRow.createCell(6).setCellValue(order.getStatusDescription());
|
|
|
297 |
contentRow.createCell(7).setCellValue(getValueForEmptyString(lineItem.getBrand()));
|
|
|
298 |
contentRow.createCell(8).setCellValue(getValueForEmptyString(lineItem.getModel_name()));
|
|
|
299 |
contentRow.createCell(9).setCellValue(getValueForEmptyString(lineItem.getModel_number()));
|
|
|
300 |
contentRow.createCell(10).setCellValue(getValueForEmptyString(lineItem.getColor()));
|
|
|
301 |
contentRow.createCell(11).setCellValue(lineItem.getQuantity());
|
|
|
302 |
contentRow.createCell(12).setCellValue(lineItem.getUnit_price());
|
|
|
303 |
contentRow.createCell(13).setCellValue(lineItem.getTotal_price());
|
|
|
304 |
contentRow.createCell(14).setCellValue(order.getCustomer_id());
|
|
|
305 |
contentRow.createCell(15).setCellValue(order.getCustomer_name());
|
|
|
306 |
contentRow.createCell(16).setCellValue(order.getCustomer_address1());
|
|
|
307 |
contentRow.createCell(17).setCellValue(order.getCustomer_address2());
|
|
|
308 |
contentRow.createCell(18).setCellValue(order.getCustomer_city());
|
|
|
309 |
contentRow.createCell(19).setCellValue(order.getCustomer_state());
|
|
|
310 |
contentRow.createCell(20).setCellValue(order.getCustomer_pincode());
|
|
|
311 |
contentRow.createCell(21).setCellValue(order.getCustomer_mobilenumber());
|
|
|
312 |
contentRow.createCell(22).setCellValue(order.getCustomer_email());
|
|
|
313 |
contentRow.createCell(23).setCellValue(order.getAirwaybill_no());
|
|
|
314 |
contentRow.createCell(24).setCellValue(order.getBilled_by());
|
|
|
315 |
contentRow.createCell(25).setCellValue(order.getReceiver());
|
|
|
316 |
contentRow.createCell(26).setCellValue(order.getTracking_id());
|
|
|
317 |
contentRow.createCell(27).setCellValue(dateFormat.format(new Date(order.getAccepted_timestamp())));
|
|
|
318 |
contentRow.createCell(28).setCellValue(dateFormat.format(new Date(order.getDelivery_timestamp())));
|
|
|
319 |
contentRow.createCell(29).setCellValue(dateFormat.format(new Date(order.getExpected_delivery_time())));
|
|
|
320 |
}
|
|
|
321 |
}
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
private String getValueForEmptyString(String s){
|
|
|
325 |
if(s==null || s.equals(""))
|
|
|
326 |
return "-";
|
|
|
327 |
else
|
|
|
328 |
return s;
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
private void createUserSheet(User user, Workbook wb, CellStyle style) {
|
|
|
332 |
Sheet userSheet = wb.createSheet("User");
|
|
|
333 |
short userSerialNo = 0;
|
|
|
334 |
// Create the header row and put all the titles in it. Rows are 0 based.
|
|
|
335 |
|
|
|
336 |
Row titleRow = userSheet.createRow(userSerialNo++);
|
|
|
337 |
Cell titleCell = titleRow.createCell(0);
|
|
|
338 |
titleCell.setCellValue("User Details");
|
|
|
339 |
titleCell.setCellStyle(style);
|
|
|
340 |
|
|
|
341 |
userSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
|
|
|
342 |
|
|
|
343 |
Row userHeaderRow = userSheet.createRow(userSerialNo++);
|
|
|
344 |
userHeaderRow.createCell(0).setCellValue("Name");
|
|
|
345 |
userHeaderRow.createCell(1).setCellValue("Email");
|
|
|
346 |
userHeaderRow.createCell(2).setCellValue("Communication Email");
|
|
|
347 |
userHeaderRow.createCell(3).setCellValue("Date Of Birth");
|
|
|
348 |
userHeaderRow.createCell(4).setCellValue("Mobile Number");
|
|
|
349 |
userHeaderRow.createCell(5).setCellValue("Sex");
|
|
|
350 |
userHeaderRow.createCell(6).setCellValue("User Id");
|
|
|
351 |
|
|
|
352 |
Row userContentRow = userSheet.createRow(userSerialNo++);
|
|
|
353 |
|
|
|
354 |
userContentRow.createCell(0).setCellValue(user.getName());
|
|
|
355 |
userContentRow.createCell(1).setCellValue(user.getEmail());
|
|
|
356 |
userContentRow.createCell(2).setCellValue(user.getCommunicationEmail());
|
|
|
357 |
userContentRow.createCell(3).setCellValue(user.getDateOfBirth());
|
|
|
358 |
userContentRow.createCell(4).setCellValue(user.getMobileNumber());
|
|
|
359 |
userContentRow.createCell(5).setCellValue(user.getSex().name());
|
|
|
360 |
userContentRow.createCell(6).setCellValue(user.getUserId());
|
|
|
361 |
|
|
|
362 |
for (Address address : user.getAddresses()) {
|
|
|
363 |
if (user.getDefaultAddressId() == address.getId()) {
|
|
|
364 |
userSerialNo+=2;
|
|
|
365 |
userContentRow = userSheet.createRow(userSerialNo);
|
|
|
366 |
userSheet.addMergedRegion(new CellRangeAddress(userSerialNo, userSerialNo, 0, 6));
|
|
|
367 |
userContentRow.createCell(0).setCellValue("Primary Address");
|
|
|
368 |
|
|
|
369 |
userSerialNo++;
|
|
|
370 |
userContentRow = userSheet.createRow(userSerialNo);
|
|
|
371 |
userContentRow.createCell(0).setCellValue(address.getName());
|
|
|
372 |
userContentRow.createCell(1).setCellValue(address.getLine1());
|
|
|
373 |
userContentRow.createCell(2).setCellValue(address.getLine2());
|
|
|
374 |
userContentRow.createCell(3).setCellValue(address.getCity());
|
|
|
375 |
userContentRow.createCell(4).setCellValue(address.getState());
|
|
|
376 |
userContentRow.createCell(5).setCellValue(address.getPin());
|
|
|
377 |
userContentRow.createCell(6).setCellValue(address.getPhone());
|
|
|
378 |
}
|
|
|
379 |
}
|
|
|
380 |
|
|
|
381 |
userSerialNo+=3;
|
|
|
382 |
userContentRow = userSheet.createRow(userSerialNo);
|
|
|
383 |
userSheet.addMergedRegion(new CellRangeAddress(userSerialNo, userSerialNo, 0, 6));
|
|
|
384 |
userContentRow.createCell(0).setCellValue("Other Addresses");
|
|
|
385 |
|
|
|
386 |
for (Address address : user.getAddresses()) {
|
|
|
387 |
if (user.getDefaultAddressId() != address.getId()) {
|
|
|
388 |
|
|
|
389 |
userSerialNo++;
|
|
|
390 |
userContentRow = userSheet.createRow(userSerialNo);
|
|
|
391 |
userContentRow.createCell(0).setCellValue(address.getName());
|
|
|
392 |
userContentRow.createCell(1).setCellValue(address.getLine1());
|
|
|
393 |
userContentRow.createCell(2).setCellValue(address.getLine2());
|
|
|
394 |
userContentRow.createCell(3).setCellValue(address.getCity());
|
|
|
395 |
userContentRow.createCell(4).setCellValue(address.getState());
|
|
|
396 |
userContentRow.createCell(5).setCellValue(address.getPin());
|
|
|
397 |
userContentRow.createCell(6).setCellValue(address.getPhone());
|
|
|
398 |
}
|
|
|
399 |
}
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
public static void main(String[] args){
|
|
|
403 |
UserOrdersController usc = new UserOrdersController();
|
|
|
404 |
usc.request = new HttpServletRequest() {
|
|
|
405 |
|
|
|
406 |
@Override
|
|
|
407 |
public void setCharacterEncoding(String arg0)
|
|
|
408 |
throws UnsupportedEncodingException {
|
|
|
409 |
// TODO Auto-generated method stub
|
|
|
410 |
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
@Override
|
|
|
414 |
public void setAttribute(String arg0, Object arg1) {
|
|
|
415 |
// TODO Auto-generated method stub
|
|
|
416 |
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
@Override
|
|
|
420 |
public void removeAttribute(String arg0) {
|
|
|
421 |
// TODO Auto-generated method stub
|
|
|
422 |
|
|
|
423 |
}
|
|
|
424 |
|
|
|
425 |
@Override
|
|
|
426 |
public boolean isSecure() {
|
|
|
427 |
// TODO Auto-generated method stub
|
|
|
428 |
return false;
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
@Override
|
|
|
432 |
public int getServerPort() {
|
|
|
433 |
// TODO Auto-generated method stub
|
|
|
434 |
return 0;
|
|
|
435 |
}
|
|
|
436 |
|
|
|
437 |
@Override
|
|
|
438 |
public String getServerName() {
|
|
|
439 |
// TODO Auto-generated method stub
|
|
|
440 |
return null;
|
|
|
441 |
}
|
|
|
442 |
|
|
|
443 |
@Override
|
|
|
444 |
public String getScheme() {
|
|
|
445 |
// TODO Auto-generated method stub
|
|
|
446 |
return null;
|
|
|
447 |
}
|
|
|
448 |
|
|
|
449 |
@Override
|
|
|
450 |
public RequestDispatcher getRequestDispatcher(String arg0) {
|
|
|
451 |
// TODO Auto-generated method stub
|
|
|
452 |
return null;
|
|
|
453 |
}
|
|
|
454 |
|
|
|
455 |
@Override
|
|
|
456 |
public int getRemotePort() {
|
|
|
457 |
// TODO Auto-generated method stub
|
|
|
458 |
return 0;
|
|
|
459 |
}
|
|
|
460 |
|
|
|
461 |
@Override
|
|
|
462 |
public String getRemoteHost() {
|
|
|
463 |
// TODO Auto-generated method stub
|
|
|
464 |
return null;
|
|
|
465 |
}
|
|
|
466 |
|
|
|
467 |
@Override
|
|
|
468 |
public String getRemoteAddr() {
|
|
|
469 |
// TODO Auto-generated method stub
|
|
|
470 |
return null;
|
|
|
471 |
}
|
|
|
472 |
|
|
|
473 |
@Override
|
|
|
474 |
public String getRealPath(String arg0) {
|
|
|
475 |
// TODO Auto-generated method stub
|
|
|
476 |
return null;
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
@Override
|
|
|
480 |
public BufferedReader getReader() throws IOException {
|
|
|
481 |
// TODO Auto-generated method stub
|
|
|
482 |
return null;
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
@Override
|
|
|
486 |
public String getProtocol() {
|
|
|
487 |
// TODO Auto-generated method stub
|
|
|
488 |
return null;
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
@Override
|
|
|
492 |
public String[] getParameterValues(String arg0) {
|
|
|
493 |
// TODO Auto-generated method stub
|
|
|
494 |
return null;
|
|
|
495 |
}
|
|
|
496 |
|
|
|
497 |
@Override
|
|
|
498 |
public Enumeration getParameterNames() {
|
|
|
499 |
// TODO Auto-generated method stub
|
|
|
500 |
return null;
|
|
|
501 |
}
|
|
|
502 |
|
|
|
503 |
@Override
|
|
|
504 |
public Map getParameterMap() {
|
|
|
505 |
// TODO Auto-generated method stub
|
|
|
506 |
return null;
|
|
|
507 |
}
|
|
|
508 |
|
|
|
509 |
@Override
|
|
|
510 |
public String getParameter(String arg0) {
|
|
|
511 |
return "test@test.com";
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
@Override
|
|
|
515 |
public Enumeration getLocales() {
|
|
|
516 |
// TODO Auto-generated method stub
|
|
|
517 |
return null;
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
@Override
|
|
|
521 |
public Locale getLocale() {
|
|
|
522 |
// TODO Auto-generated method stub
|
|
|
523 |
return null;
|
|
|
524 |
}
|
|
|
525 |
|
|
|
526 |
@Override
|
|
|
527 |
public int getLocalPort() {
|
|
|
528 |
// TODO Auto-generated method stub
|
|
|
529 |
return 0;
|
|
|
530 |
}
|
|
|
531 |
|
|
|
532 |
@Override
|
|
|
533 |
public String getLocalName() {
|
|
|
534 |
// TODO Auto-generated method stub
|
|
|
535 |
return null;
|
|
|
536 |
}
|
|
|
537 |
|
|
|
538 |
@Override
|
|
|
539 |
public String getLocalAddr() {
|
|
|
540 |
// TODO Auto-generated method stub
|
|
|
541 |
return null;
|
|
|
542 |
}
|
|
|
543 |
|
|
|
544 |
@Override
|
|
|
545 |
public ServletInputStream getInputStream() throws IOException {
|
|
|
546 |
// TODO Auto-generated method stub
|
|
|
547 |
return null;
|
|
|
548 |
}
|
|
|
549 |
|
|
|
550 |
@Override
|
|
|
551 |
public String getContentType() {
|
|
|
552 |
// TODO Auto-generated method stub
|
|
|
553 |
return null;
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
@Override
|
|
|
557 |
public int getContentLength() {
|
|
|
558 |
// TODO Auto-generated method stub
|
|
|
559 |
return 0;
|
|
|
560 |
}
|
|
|
561 |
|
|
|
562 |
@Override
|
|
|
563 |
public String getCharacterEncoding() {
|
|
|
564 |
// TODO Auto-generated method stub
|
|
|
565 |
return null;
|
|
|
566 |
}
|
|
|
567 |
|
|
|
568 |
@Override
|
|
|
569 |
public Enumeration getAttributeNames() {
|
|
|
570 |
// TODO Auto-generated method stub
|
|
|
571 |
return null;
|
|
|
572 |
}
|
|
|
573 |
|
|
|
574 |
@Override
|
|
|
575 |
public Object getAttribute(String arg0) {
|
|
|
576 |
// TODO Auto-generated method stub
|
|
|
577 |
return null;
|
|
|
578 |
}
|
|
|
579 |
|
|
|
580 |
@Override
|
|
|
581 |
public boolean isUserInRole(String arg0) {
|
|
|
582 |
// TODO Auto-generated method stub
|
|
|
583 |
return false;
|
|
|
584 |
}
|
|
|
585 |
|
|
|
586 |
@Override
|
|
|
587 |
public boolean isRequestedSessionIdValid() {
|
|
|
588 |
// TODO Auto-generated method stub
|
|
|
589 |
return false;
|
|
|
590 |
}
|
|
|
591 |
|
|
|
592 |
@Override
|
|
|
593 |
public boolean isRequestedSessionIdFromUrl() {
|
|
|
594 |
// TODO Auto-generated method stub
|
|
|
595 |
return false;
|
|
|
596 |
}
|
|
|
597 |
|
|
|
598 |
@Override
|
|
|
599 |
public boolean isRequestedSessionIdFromURL() {
|
|
|
600 |
// TODO Auto-generated method stub
|
|
|
601 |
return false;
|
|
|
602 |
}
|
|
|
603 |
|
|
|
604 |
@Override
|
|
|
605 |
public boolean isRequestedSessionIdFromCookie() {
|
|
|
606 |
// TODO Auto-generated method stub
|
|
|
607 |
return false;
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
@Override
|
|
|
611 |
public Principal getUserPrincipal() {
|
|
|
612 |
// TODO Auto-generated method stub
|
|
|
613 |
return null;
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
@Override
|
|
|
617 |
public HttpSession getSession(boolean arg0) {
|
|
|
618 |
// TODO Auto-generated method stub
|
|
|
619 |
return null;
|
|
|
620 |
}
|
|
|
621 |
|
|
|
622 |
@Override
|
|
|
623 |
public HttpSession getSession() {
|
|
|
624 |
// TODO Auto-generated method stub
|
|
|
625 |
return null;
|
|
|
626 |
}
|
|
|
627 |
|
|
|
628 |
@Override
|
|
|
629 |
public String getServletPath() {
|
|
|
630 |
// TODO Auto-generated method stub
|
|
|
631 |
return null;
|
|
|
632 |
}
|
|
|
633 |
|
|
|
634 |
@Override
|
|
|
635 |
public String getRequestedSessionId() {
|
|
|
636 |
// TODO Auto-generated method stub
|
|
|
637 |
return null;
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
@Override
|
|
|
641 |
public StringBuffer getRequestURL() {
|
|
|
642 |
// TODO Auto-generated method stub
|
|
|
643 |
return null;
|
|
|
644 |
}
|
|
|
645 |
|
|
|
646 |
@Override
|
|
|
647 |
public String getRequestURI() {
|
|
|
648 |
// TODO Auto-generated method stub
|
|
|
649 |
return null;
|
|
|
650 |
}
|
|
|
651 |
|
|
|
652 |
@Override
|
|
|
653 |
public String getRemoteUser() {
|
|
|
654 |
// TODO Auto-generated method stub
|
|
|
655 |
return null;
|
|
|
656 |
}
|
|
|
657 |
|
|
|
658 |
@Override
|
|
|
659 |
public String getQueryString() {
|
|
|
660 |
// TODO Auto-generated method stub
|
|
|
661 |
return null;
|
|
|
662 |
}
|
|
|
663 |
|
|
|
664 |
@Override
|
|
|
665 |
public String getPathTranslated() {
|
|
|
666 |
// TODO Auto-generated method stub
|
|
|
667 |
return null;
|
|
|
668 |
}
|
|
|
669 |
|
|
|
670 |
@Override
|
|
|
671 |
public String getPathInfo() {
|
|
|
672 |
// TODO Auto-generated method stub
|
|
|
673 |
return null;
|
|
|
674 |
}
|
|
|
675 |
|
|
|
676 |
@Override
|
|
|
677 |
public String getMethod() {
|
|
|
678 |
// TODO Auto-generated method stub
|
|
|
679 |
return null;
|
|
|
680 |
}
|
|
|
681 |
|
|
|
682 |
@Override
|
|
|
683 |
public int getIntHeader(String arg0) {
|
|
|
684 |
// TODO Auto-generated method stub
|
|
|
685 |
return 0;
|
|
|
686 |
}
|
|
|
687 |
|
|
|
688 |
@Override
|
|
|
689 |
public Enumeration getHeaders(String arg0) {
|
|
|
690 |
// TODO Auto-generated method stub
|
|
|
691 |
return null;
|
|
|
692 |
}
|
|
|
693 |
|
|
|
694 |
@Override
|
|
|
695 |
public Enumeration getHeaderNames() {
|
|
|
696 |
// TODO Auto-generated method stub
|
|
|
697 |
return null;
|
|
|
698 |
}
|
|
|
699 |
|
|
|
700 |
@Override
|
|
|
701 |
public String getHeader(String arg0) {
|
|
|
702 |
// TODO Auto-generated method stub
|
|
|
703 |
return null;
|
|
|
704 |
}
|
|
|
705 |
|
|
|
706 |
@Override
|
|
|
707 |
public long getDateHeader(String arg0) {
|
|
|
708 |
// TODO Auto-generated method stub
|
|
|
709 |
return 0;
|
|
|
710 |
}
|
|
|
711 |
|
|
|
712 |
@Override
|
|
|
713 |
public Cookie[] getCookies() {
|
|
|
714 |
// TODO Auto-generated method stub
|
|
|
715 |
return null;
|
|
|
716 |
}
|
|
|
717 |
|
|
|
718 |
@Override
|
|
|
719 |
public String getContextPath() {
|
|
|
720 |
// TODO Auto-generated method stub
|
|
|
721 |
return null;
|
|
|
722 |
}
|
|
|
723 |
|
|
|
724 |
@Override
|
|
|
725 |
public String getAuthType() {
|
|
|
726 |
// TODO Auto-generated method stub
|
|
|
727 |
return null;
|
|
|
728 |
}
|
|
|
729 |
};
|
|
|
730 |
usc.create();
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
public String getErrorMsg() {
|
|
|
734 |
return errorMsg;
|
|
|
735 |
}
|
|
|
736 |
}
|
|
|
737 |
|