Subversion Repositories SmartDukaan

Rev

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

Rev 1023 Rev 1367
Line 12... Line 12...
12
 
12
 
13
import org.apache.struts2.rest.DefaultHttpHeaders;
13
import org.apache.struts2.rest.DefaultHttpHeaders;
14
import org.apache.struts2.rest.HttpHeaders;
14
import org.apache.struts2.rest.HttpHeaders;
15
import com.opensymphony.xwork2.ModelDriven;
15
import com.opensymphony.xwork2.ModelDriven;
16
 
16
 
17
public class UpdatesController implements ModelDriven<Object>{
17
public class UpdatesController implements ModelDriven<InventoryUpdate>{
18
 
18
 
19
	private InventoryUpdate inventoryUpdate = new InventoryUpdate();
19
	private InventoryUpdate inventoryUpdate = new InventoryUpdate();
20
	private String timestamp;
20
	private String timestamp;
21
	
21
	
22
	private int errorCode = 0;
22
	private int errorCode = 0;
Line 28... Line 28...
28
	public UpdatesController(){
28
	public UpdatesController(){
29
		
29
		
30
	}
30
	}
31
	
31
	
32
	@Override
32
	@Override
33
	public Object getModel() {
33
	public InventoryUpdate getModel() {
34
		return this.inventoryUpdate;
34
		return this.inventoryUpdate;
35
	}
35
	}
36
	
36
	
37
	public HttpHeaders show(){
37
	public HttpHeaders show(){
38
		System.out.println("Warehouse Id is:  " + getId());
38
		System.out.println("Warehouse Id is:  " + getId());
Line 63... Line 63...
63
			Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
63
			Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
64
			String timestamp = inventoryUpdate.getCurrentTimestamp();
64
			String timestamp = inventoryUpdate.getCurrentTimestamp();
65
			Map<String, Long> availability = new HashMap<String, Long>();
65
			Map<String, Long> availability = new HashMap<String, Long>();
66
			List<Update> updates = inventoryUpdate.getUpdates();
66
			List<Update> updates = inventoryUpdate.getUpdates();
67
			for(Update update: updates){
67
			for(Update update: updates){
68
				String group = update.getGroup().trim();
-
 
69
				String brand = update.getBrand().trim();
-
 
70
				String model = update.getModel().trim();
68
				String key = update.getKey();
71
				String color = update.getColor().trim();
-
 
72
				String key = group + ";" + brand + ";" + model + ";" + color;
-
 
73
				long quantity = (long) Double.parseDouble(update.getQuantity());
69
				long quantity = (long) Double.parseDouble(update.getQuantity());
74
				if(availability.containsKey(key)){
70
				if(availability.containsKey(key)){
75
					quantity = quantity + availability.get(key);
71
					quantity = quantity + availability.get(key);
76
				}
72
				}
77
				availability.put(key, quantity);
73
				availability.put(key, quantity);