| 3546 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.utils;
|
|
|
5 |
|
| 4142 |
mandeep.dh |
6 |
import in.shop2020.model.v1.catalog.Item;
|
| 3546 |
mandeep.dh |
7 |
import in.shop2020.model.v1.order.LineItem;
|
|
|
8 |
import in.shop2020.model.v1.order.Order;
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* @author mandeep
|
|
|
12 |
*
|
|
|
13 |
*/
|
|
|
14 |
public class ModelUtils {
|
|
|
15 |
public static String extractAddressFromOrder(Order order) {
|
|
|
16 |
StringBuilder address = new StringBuilder();
|
|
|
17 |
if (order.getCustomer_address1() != null) {
|
|
|
18 |
address.append(order.getCustomer_address1() + ", ");
|
|
|
19 |
}
|
|
|
20 |
if (order.getCustomer_address2() != null) {
|
|
|
21 |
address.append(order.getCustomer_address2() + ", ");
|
|
|
22 |
}
|
|
|
23 |
if (order.getCustomer_city() != null) {
|
|
|
24 |
address.append(order.getCustomer_city() + ", ");
|
|
|
25 |
}
|
|
|
26 |
if (order.getCustomer_state() != null) {
|
|
|
27 |
address.append(order.getCustomer_state() + "-");
|
|
|
28 |
}
|
|
|
29 |
if (order.getCustomer_pincode() != null) {
|
|
|
30 |
address.append(order.getCustomer_pincode());
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
return address.toString();
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
public static String extractProductNameFromLineItem(LineItem lineItem) {
|
|
|
37 |
StringBuilder productName = new StringBuilder();
|
|
|
38 |
|
|
|
39 |
if (lineItem.getBrand() != null && !lineItem.getBrand().isEmpty()) {
|
|
|
40 |
productName.append(lineItem.getBrand() + " ");
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
if (lineItem.getModel_name() != null && !lineItem.getModel_name().isEmpty()) {
|
|
|
44 |
productName.append(lineItem.getModel_name() + " ");
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
if (lineItem.getModel_number() != null && !lineItem.getModel_number().isEmpty()) {
|
|
|
48 |
productName.append(lineItem.getModel_number() + " ");
|
|
|
49 |
}
|
|
|
50 |
|
|
|
51 |
return productName.toString();
|
|
|
52 |
}
|
| 4142 |
mandeep.dh |
53 |
|
| 4294 |
varun.gupt |
54 |
public static String extractProductNameFromItem(Item item) {
|
| 4142 |
mandeep.dh |
55 |
StringBuilder productName = new StringBuilder();
|
|
|
56 |
|
| 4294 |
varun.gupt |
57 |
if (item.getBrand() != null && !item.getBrand().isEmpty()) {
|
|
|
58 |
productName.append(item.getBrand() + " ");
|
| 4142 |
mandeep.dh |
59 |
}
|
|
|
60 |
|
| 4294 |
varun.gupt |
61 |
if (item.getModelName() != null && !item.getModelName().isEmpty()) {
|
|
|
62 |
productName.append(item.getModelName() + " ");
|
| 4142 |
mandeep.dh |
63 |
}
|
|
|
64 |
|
| 4294 |
varun.gupt |
65 |
if (item.getModelNumber() != null && !item.getModelNumber().isEmpty()) {
|
|
|
66 |
productName.append(item.getModelNumber() + " ");
|
| 4142 |
mandeep.dh |
67 |
}
|
| 4294 |
varun.gupt |
68 |
|
|
|
69 |
if (item.getColor() != null && !item.getColor().isEmpty()) {
|
|
|
70 |
productName.append(item.getColor());
|
|
|
71 |
}
|
| 4142 |
mandeep.dh |
72 |
return productName.toString();
|
|
|
73 |
}
|
| 4294 |
varun.gupt |
74 |
}
|