Package com.google.code.magja.model.order

Examples of com.google.code.magja.model.order.Order


   * @return Order
   * @throws ServiceException
   */
  private Order buildOrderObject(Map<String, Object> attributes)
      throws ServiceException {
    Order order = new Order();

    for (Map.Entry<String, Object> att : attributes.entrySet())
      order.set(att.getKey(), att.getValue());

    // customer
    if (attributes.get("customer_id") != null) {
      Customer customer = new Customer();

      customer.setId(new Integer((String) attributes.get("customer_id")));
      if (attributes.get("customer_email") != null)
        customer.setEmail((String) attributes.get("customer_email"));
      if (attributes.get("customer_prefix") != null)
        customer.setPrefix((String) attributes.get("customer_prefix"));
      if (attributes.get("customer_firstname") != null)
        customer.setFirstName((String) attributes
            .get("customer_firstname"));
      if (attributes.get("customer_middlename") != null)
        customer.setMiddleName((String) attributes
            .get("customer_middlename"));
      if (attributes.get("customer_lastname") != null)
        customer.setLastName((String) attributes
            .get("customer_lastname"));
      if (attributes.get("customer_lastname") != null)
        customer.setLastName((String) attributes
            .get("customer_lastname"));
      if (attributes.get("customer_group_id") != null)
        customer.setGroupId(new Integer((String) attributes
            .get("customer_group_id")));
      if (attributes.get("customer_gender") != null) {
        Integer gender = new Integer((String) attributes
            .get("customer_gender"));
        customer.setGender(gender.equals(new Integer(1)) ? Gender.MALE
            : Gender.FEMALE);
      }

      order.setCustomer(customer);
    }

    // shipping address
    if (attributes.get("shipping_address") != null) {
      OrderAddress shippingAddress = new OrderAddress();

      Map<String, Object> atts = (Map<String, Object>) attributes
          .get("shipping_address");
      for (Map.Entry<String, Object> att : atts.entrySet())
        shippingAddress.set(att.getKey(), att.getValue());

      order.setShippingAddress(shippingAddress);
    }

    // billing address
    if (attributes.get("billing_address") != null) {
      OrderAddress billingAddress = new OrderAddress();

      Map<String, Object> atts = (Map<String, Object>) attributes
          .get("billing_address");
      for (Map.Entry<String, Object> att : atts.entrySet())
        billingAddress.set(att.getKey(), att.getValue());

      order.setBillingAddress(billingAddress);
    }

    // items
    if (attributes.get("items") != null) {
      List<Map<String, Object>> res = (List<Map<String, Object>>) attributes
          .get("items");

      for (Map<String, Object> i : res) {
        OrderItem item = new OrderItem();
        for (Map.Entry<String, Object> att : i.entrySet())
          item.set(att.getKey(), att.getValue());

        order.getItems().add(item);
      }
    }

    return order;
  }
View Full Code Here


   * Test method for {@link com.google.code.magja.service.order.OrderRemoteServiceImpl#addComment(com.google.code.magja.model.order.Order, java.lang.String, java.lang.String, java.lang.Boolean)}.
   */
  @Test
  public void testAddComment() {

    Order order = new Order();
    order.setId(100000001);

    try {
      service.addComment(order, "pending", "Hello World", false);
    } catch (ServiceException e) {
      fail(e.getMessage());
View Full Code Here

   * Test method for {@link com.google.code.magja.service.order.OrderRemoteServiceImpl#cancel(com.google.code.magja.model.order.Order)}.
   */
  @Test
  public void testCancel() {

    Order order = new Order();
    order.setId(100000001);

    try {
      service.cancel(order);
    } catch (ServiceException e) {
      fail(e.getMessage());
View Full Code Here

   */
  @Test
  public void testGetById() {

    try {
      Order order = service.getById(100000001);
      //System.out.println(order.toString());

      //System.out.println(order.getCustomer().toString());
      //System.out.println(order.getShippingAddress().toString());
      //System.out.println(order.getBillingAddress().toString());
View Full Code Here

TOP

Related Classes of com.google.code.magja.model.order.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.