List of usage examples for com.google.gson GsonBuilder create
public Gson create()
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_SIZE_LIST) public ClientResponse getProductSizeList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //ProductSizeList response = new ProductSizeList(); //response.setProductSizes(productManager.getProductSizes()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getProductSizes()); ProductSizeList response = gson.fromJson("{\"productSizes\":" + productString + "}", ProductSizeList.class); response.setSuccess(true);//from w w w. ja v a 2 s. co m return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_CATEGORY_LIST) public ClientResponse getProductCategoryList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //ProductCategoryList response = new ProductCategoryList(); //response.setProductCategories(productManager.getProductCategories()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getProductCategories()); ProductCategoryList response = gson.fromJson("{\"productCategories\":" + productString + "}", ProductCategoryList.class); response.setSuccess(true);/*from ww w .j av a2 s .c o m*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_LOCATION_LIST) public ClientResponse getLocationList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //LocationList response = new Gson().fromJson("{\"locations\":[{\"id\":\"1\",\"locationType\":\"area\",\"searchString\":\"London\",\"postCode\":\"c1\"}, {\"id\":\"2\",\"locationType\":\"area\",\"searchString\":\"London 123\",\"postCode\":\"c2\"}, {\"id\":\"3\",\"locationType\":\"area\",\"searchString\":\"London 456\",\"postCode\":\"c3\"}]}", LocationList.class ); //LocationList response = new LocationList(); //response.setLocations(productManager.getLocations()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getLocations()); LocationList response = gson.fromJson("{\"locations\":" + productString + "}", LocationList.class); response.setSuccess(true);/*from w w w .j ava2 s. c o m*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PRODUCT_AMENITY_LIST) public ClientResponse getAmenityList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String amenityListString = gson.toJson(productManager.getAmenities()); AmenityList response = gson.fromJson("{\"amenities\":" + amenityListString + "}", AmenityList.class); response.setSuccess(true);/* w w w . j a v a2s. com*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_AVAILABILITY_LIST) public ClientResponse getAvailabilityList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String availabilitiesString = gson.toJson(productManager.getAvailabilities()); AvailabilityList response = gson.fromJson("{\"availabilities\":" + availabilitiesString + "}", AvailabilityList.class); response.setSuccess(true);/*w w w . ja va 2 s .c o m*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_STAY_LIST) public ClientResponse getStayList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //StayList response = new StayList(); //response.setStays(productManager.getStays()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getStays()); StayList response = gson.fromJson("{\"stays\":" + productString + "}", StayList.class); response.setSuccess(true);/*from ww w . j a va 2s.co m*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_SMOKING_LIST) public ClientResponse getSmokingList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //SmokingList response = new SmokingList(); //response.setSmokings(productManager.getSmokings()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getSmokings()); SmokingList response = gson.fromJson("{\"smokings\":" + productString + "}", SmokingList.class); response.setSuccess(true);/*w w w .jav a 2 s.co m*/ return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_OCCUPATION_LIST) public ClientResponse getOccupationList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //OccupationList response = new OccupationList(); //response.setOccupations(productManager.getOccupations()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getOccupations()); OccupationList response = gson.fromJson("{\"occupations\":" + productString + "}", OccupationList.class); response.setSuccess(true);//from ww w.j a v a 2 s.c o m return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_PET_LIST) public ClientResponse getPetList(ISession session, IPacket packet) { ProductManager productManager = new ProductManager(); //PetList response = new PetList(); //response.setPets(productManager.getPets()); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(productManager.getPets()); PetList response = gson.fromJson("{\"pets\":" + productString + "}", PetList.class); response.setSuccess(true);//from w ww .ja v a2s . com return response; }
From source file:com.auction.request.handler.RequestHandler.java
@ClientRequest(action = ACTION.FETCH_MY_PRODUCT_LIST) public ClientResponse getMyProductList(ISession session, IPacket packet) { int userId = (int) session.getUserId(); ProductManager productManager = new ProductManager(); List<Product> products = productManager.getMyProducts(userId, 0, 100); GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY); Gson gson = gsonBuilder.create(); String productString = gson.toJson(products); //System.out.println(productString); ProductList response = gson.fromJson("{\"products\":" + productString + "}", ProductList.class); // ProductList response = new Gson().fromJson("{\"products\":[{\"id\":\"1\",\"title\":\"Fun at the Bowling Alley1\", \"img\":\"a.jpg\", \"price\":\"100\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR1.\"}, {\"id\":\"2\",\"title\":\"Fun at the Bowling Alley2\", \"img\":\"a.jpg\", \"price\":\"200\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR2.\"}, {\"id\":\"3\",\"title\":\"Fun at the Bowling Alley3\", \"img\":\"a.jpg\", \"price\":\"300\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR3.\"}, {\"id\":\"4\",\"title\":\"Fun at the Bowling Alley4\", \"img\":\"a.jpg\", \"price\":\"400\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR4.\"}, {\"id\":\"5\",\"title\":\"Fun at the Bowling Alley5\", \"img\":\"a.jpg\", \"price\":\"500\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR5.\"}, {\"id\":\"6\",\"title\":\"Fun at the Bowling Alley6\", \"img\":\"a.jpg\", \"price\":\"600\", \"price_type\":\"pw\", \"size\":\"single\", \"images\":[{\"id\":\"1\", \"url\":\"a.jpg\"}, {\"id\":\"2\", \"url\":\"b.jpg\"}], \"available\":\"2017-04-18\", \"description\":\"Double room in E16 available from 17/04/2017, short walk away from Prince Regent Lane DLR6.\"} ]}", ProductList.class ); response.setSuccess(true);/* www. j a va 2s .c om*/ return response; }