Rev 8641 | Blame | Last modification | View Log | RSS feed
package in.shop2020;import in.shop2020.model.v1.catalog.CatalogService.Client;import in.shop2020.model.v1.catalog.Item;import in.shop2020.thrift.clients.CatalogClient;import java.io.File;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Date;import java.util.List;import java.util.Random;import javax.xml.bind.JAXBContext;import javax.xml.bind.JAXBException;import javax.xml.bind.Marshaller;import org.apache.thrift.TException;import org.apache.thrift.transport.TTransportException;import pricing.SaholicAPI;import pricing.SaholicAPI.Price;import utilities.ScpService;public class CreateSnapDealPricingFeed {private static final String SNAPDEAL_PRICING_XML = "/home/snapdeal-pricing.xml";public static void main(String... args){CatalogClient catalogServiceClient = null;try {catalogServiceClient = new CatalogClient();} catch (TTransportException e) {// TODO Auto-generated catch blocke.printStackTrace();}Client catalogClient = catalogServiceClient.getClient();try {List<Item> items = catalogClient.getAllSnapdealListedActiveItems();File file = new File(SNAPDEAL_PRICING_XML);JAXBContext context;Marshaller m=null;try {context = JAXBContext.newInstance(SaholicAPI.class);m = context.createMarshaller();} catch (JAXBException e1) {// TODO Auto-generated catch blocke1.printStackTrace();}SaholicAPI saholicAPI = new SaholicAPI();DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");Date date = new Date();saholicAPI.setCreateDate(dateFormat.format(date));saholicAPI.setFeedIdentifier(date.getTime());List<Price> priceList = saholicAPI.getPrice();if(items.size() > 0){for(Item item : items){Price price = new Price();price.setSKU(item.getId());price.setMrp(item.getMrp());price.setSellingPrice(item.getSellingPrice());priceList.add(price);}try {m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);m.marshal(saholicAPI, file);m.marshal(saholicAPI, System.out);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}else{System.out.println("No Snapdeal listed Active items");}ScpService scpService = new ScpService();scpService.scpFile("/var/www/static.saholic.com/partners",SNAPDEAL_PRICING_XML);} catch (TException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}