Package com.google.greaze.example.definition.model

Examples of com.google.greaze.example.definition.model.Order


    ExampleClient client = new ExampleClient();
    List<LineItem> lineItems = new ArrayList<LineItem>();
    lineItems.add(new LineItem("item1", 2, 1000000L, "USD"));
  Cart cart = new Cart(lineItems, "first last", "4111-1111-1111-1111");
  String authToken = "authToken";
  Order order = client.placeOrder(cart, authToken );
  System.out.print(order);
  }
View Full Code Here


  private Cart createCart(Cart cart) {
    return cartRestClient.post(cart, new WebContext());
  }

  public Order placeOrder(Cart cart) {
    Order order = new Order(cart, cart.getId().getValue());
    return orderRestClient.post(order, new WebContext());
  }
View Full Code Here

    List<LineItem> lineItems = new ArrayList<LineItem>();
    String itemName = "cheese";
    lineItems.add(new LineItem(itemName, 2, 1000000L, "USD"));
    Cart cart = new Cart(lineItems, "Hungry Bird", "4111-1111-1111-1111");
    cart = client.createCart(cart);
    Order order = client.placeOrder(cart);
 
    System.out.println("Placed order: " + gson.toJson(order));
    List<Order> queriedOrders = client.query(itemName);
    System.out.printf("Queried orders by item name (%s): %s\n",
        itemName, gson.toJson(queriedOrders));
View Full Code Here

  public List<Order> query(QueryOrdersByItemName query, WebContext context) {
    long repoSize = Long.parseLong(orders.getNextId().getValue());
    List<Order> results = Lists.newArrayList();
    for (int i = 0; i < repoSize; ++i) {
      Id<Order> orderId = Id.get(String.valueOf(i));
      Order order = orders.get(orderId);
      if (order == null) {
        continue;
      }
      for (LineItem item : order.getPostedCart().getLineItems()) {
        if (item.getName().equals(query.getItemName())) {
          results.add(order);
        }
      }
    }
View Full Code Here

  protected WebServiceResponse buildResponse(ResponseSpec responseSpec,
      WebServiceRequest webServiceRequest) {
    Cart cart = webServiceRequest.getBody().get(TypedKeys.RequestBody.CART);
    String authToken = webServiceRequest.getHeader(TypedKeys.Request.AUTH_TOKEN);

    Order order = placeOrder(cart, authToken);

    // Empty headers per the spec
    HeaderMap responseHeaders = new HeaderMap.Builder(responseSpec.getHeadersSpec()).build();
    ResponseBody responseBody = new ResponseBody.Builder(responseSpec.getBodySpec())
        .put(TypedKeys.ResponseBody.ORDER, order)
View Full Code Here

    return new WebServiceResponse(responseHeaders, responseBody);
  }
 
  private Order placeOrder(Cart cart, String authToken) {
    // Create an order, in this case a dummy one.
    return new Order(cart, "Order123");
  }
View Full Code Here

TOP

Related Classes of com.google.greaze.example.definition.model.Order

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.