Subversion Repositories SmartDukaan

Rev

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

Rev 3126 Rev 3209
Line 1... Line 1...
1
package in.shop2020.serving.utils;
1
package in.shop2020.serving.utils;
2
 
2
 
3
import org.apache.log4j.Logger;
-
 
4
 
-
 
5
import in.shop2020.config.ConfigException;
3
import in.shop2020.config.ConfigException;
6
import in.shop2020.model.v1.catalog.InventoryService.Client;
4
import in.shop2020.model.v1.catalog.InventoryService.Client;
7
import in.shop2020.model.v1.catalog.Item;
5
import in.shop2020.model.v1.catalog.Item;
-
 
6
import in.shop2020.model.v1.order.LineItem;
-
 
7
import in.shop2020.model.v1.order.Order;
-
 
8
import in.shop2020.model.v1.user.Cart;
-
 
9
import in.shop2020.model.v1.user.Line;
8
import in.shop2020.thrift.clients.CatalogClient;
10
import in.shop2020.thrift.clients.CatalogClient;
9
import in.shop2020.thrift.clients.config.ConfigClient;
11
import in.shop2020.thrift.clients.config.ConfigClient;
10
 
12
 
-
 
13
import java.util.ArrayList;
-
 
14
import java.util.List;
-
 
15
 
-
 
16
import org.apache.commons.lang.StringUtils;
-
 
17
import org.apache.log4j.Logger;
-
 
18
 
11
public class Utils {
19
public class Utils {
12
    private static Logger logger = Logger.getLogger(Utils.class);
20
    private static Logger logger = Logger.getLogger(Utils.class);
13
    
21
    
14
	public static final String EXPORT_ENTITIES_PATH = getExportPath();
22
	public static final String EXPORT_ENTITIES_PATH = getExportPath();
15
	public static final long ROOT_CATEGORY = 10000;
23
	public static final long ROOT_CATEGORY = 10000;
Line 111... Line 119...
111
		if (iPhone < 1000000000l || iPhone > 9999999999l) {
119
		if (iPhone < 1000000000l || iPhone > 9999999999l) {
112
			return false;
120
			return false;
113
		}
121
		}
114
		return true;
122
		return true;
115
	}
123
	}
-
 
124
	
-
 
125
	public static String getItemIdStringInCart(Cart cart) {
-
 
126
	    List<String> itemIds = new ArrayList<String>();
-
 
127
        for (Line line : cart.getLines()) {
-
 
128
            itemIds.add(Long.toString(line.getItemId()));
-
 
129
        }
-
 
130
        return StringUtils.join(itemIds, '_');
-
 
131
    }
-
 
132
	
-
 
133
	public static String getItemIdStringFromOrders(List<Order> orders) {
-
 
134
        List<String> itemIds = new ArrayList<String>();
-
 
135
        if (orders != null) {
-
 
136
            for (Order order : orders) {
-
 
137
                for (LineItem lItem : order.getLineitems()) {
-
 
138
                    itemIds.add(Long.toString(lItem.getItem_id()));
-
 
139
                }
-
 
140
            }
-
 
141
        }
-
 
142
        return StringUtils.join(itemIds, '_');
-
 
143
    }
116
 
144
 
117
	
145
	
118
//	public static void main(String args[]) throws Exception{
146
//	public static void main(String args[]) throws Exception{
119
//		// to store categories
147
//		// to store categories
120
//		Map<Long, Category> categories = new HashMap<Long, Category>();
148
//		Map<Long, Category> categories = new HashMap<Long, Category>();