Subversion Repositories SmartDukaan

Rev

Rev 7026 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package in.shop2020.serving.controllers;

import in.shop2020.config.ConfigException;
import in.shop2020.serving.model.ShipmentUpdate;
import in.shop2020.thrift.clients.TransactionClient;

import java.util.List;
import java.util.ArrayList;

import org.apache.log4j.Logger;

public class RedexpressUpdatesController extends BaseController {

        private static final long serialVersionUID = -7381937038033808767L;

        private static Logger log = Logger.getLogger(Class.class);
        private String id;
        private List<ShipmentUpdate> updates = new ArrayList<ShipmentUpdate>();

        public RedexpressUpdatesController(){
                super();
        }

        public String show() {
        log.info("RedExpress Updates Controller " + id);
        try{
                TransactionClient tc = new TransactionClient();
                List<String> tokens= tc.getClient().receiveUpdatesForRedExpress(id);
                for(String token: tokens){
                        String[] parts = token.split("~!~");
                        ShipmentUpdate update = new ShipmentUpdate();
                        update.date = parts[0];
                        update.time = "          " + parts[1];
                        update.description = parts[2];
                        update.city = "--";
                        updates.add(update);
                }
        } catch (Exception e) {
                log.info("Some problem while fetching");
        }
                return "show";
        }

        public String getId(){
                return id;
        }

        public void setId(String id){
                this.id = id;
        }

        public  List<ShipmentUpdate> getUpdates(){
                return updates;
        }
}