public String execute() throws Exception { Offer offer = new Offer(); offer.setDescription(description); offer.setStartingCity(startingCity); offer.setFinishingCity(finishingCity); offer.setNumberOfPlaceInitial(numberOfPassengers); offer.setNumberOfPlaceRemaining(numberOfPassengers); offer.setPricePerPassenger(pricePerPassenger); Route route = new Route(); route.setStartingAddress(""); route.setStartingCity(startingCity); route.setFinishingAddress(""); route.setFinishingCity(finishingCity); route.setRouteOrder(1); route.setPrice(0f); route.setConversionRateToEuro(0f); route.setCurrencyCode(""); List<Route> routes = new ArrayList<Route>(); routes.add(route); OfferDAO offerDAO = SpringDAO.getSpring().getOfferDAO(); offerDAO.saveOfferWithRoutes(offer, routes, idCustomerAccount, isDriver); return SUCCESS; }
public void saveOfferWithRoutes( Offer offer, Route route, Integer idCustomerAccount, Integer isDriver) { List<NameValuePair> paramsToPost = new ArrayList<NameValuePair>(); paramsToPost.add(new BasicNameValuePair("idCustomerAccount", idCustomerAccount.toString())); paramsToPost.add(new BasicNameValuePair("isDriver", isDriver.toString())); paramsToPost.add(new BasicNameValuePair("description", offer.getDescription())); paramsToPost.add( new BasicNameValuePair("numberOfPassengers", offer.getNumberOfPlaceInitial().toString())); paramsToPost.add( new BasicNameValuePair("pricePerPassenger", offer.getPricePerPassenger().toString())); paramsToPost.add(new BasicNameValuePair("startingCity", route.getStartingCity().toString())); paramsToPost.add(new BasicNameValuePair("finishingCity", route.getFinishingCity().toString())); // paramsToPost.add(new BasicNameValuePair("price", route.getPrice().toString())); // Send the HTTP request HttpClient.SendHttpPost(URL, jsonObjectSend, paramsToPost); }