Esempio n. 1
0
 OrderInfoImpl() {
   Order order = new Order();
   order.setOrderId(1);
   order.setItemName("Soap");
   order.setQuantity(120);
   order.setCustomerName("Sandeep");
   order.setShippingAddress("Gurgaon");
   list.add(0, order);
   order = new Order();
   order.setOrderId(2);
   order.setItemName("Shampoo");
   order.setQuantity(50);
   order.setCustomerName("Sandeep");
   order.setShippingAddress("Gurgaon");
   list.add(1, order);
 }
 protected Object expectedDomainObject() {
   Order order = new Order();
   Calendar calendar = Calendar.getInstance();
   calendar.set(2007, 0, 1, 0, 0, 0);
   calendar.set(Calendar.MILLISECOND, 0);
   order.setOrderDate(calendar.getTime());
   order.setOrderId(ORDER_ID);
   return order;
 }
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    entityManagerFactory = Persistence.createEntityManagerFactory("customerPersistenceUnit");
    EntityManager entityManager = entityManagerFactory.createEntityManager();

    Customer customer;
    Order order1;
    Order order2;

    order1 = new Order();
    order1.setOrderId(1L);
    order1.setOrderNumber("SFX12345");
    order1.setOrderDescription("Dummy order.");

    order2 = new Order();
    order2.setOrderId(2L);
    order2.setOrderNumber("SFX23456");
    order2.setOrderDescription("Another dummy order.");

    try {
      entityManager.getTransaction().begin();

      customer = entityManager.find(Customer.class, 4L);

      order1.setCustomer(customer);
      order2.setCustomer(customer);

      entityManager.persist(order1);
      entityManager.persist(order2);

      entityManager.getTransaction().commit();

      response.getWriter().println("Database updated successfully.");
    } catch (IllegalStateException e) {
      e.printStackTrace();
    }
  }
Esempio n. 4
0
  public static Order getOrder(Element orderinfoelement) {

    Order o = new Order();

    NodeList personnodes = orderinfoelement.getElementsByTagName("person_info");

    Element personlement = (Element) personnodes.item(0);

    o.setReceiverName(DOMHelper.getSubElementVauleByName(personlement, "receivername"));
    o.setbuyerNick(DOMHelper.getSubElementVauleByName(personlement, "name"));
    o.setEmail(DOMHelper.getSubElementVauleByName(personlement, "email"));
    o.setMobilePhone(DOMHelper.getSubElementVauleByName(personlement, "mobilephone"));

    o.setRemarks(DOMHelper.getSubElementVauleByName(personlement, "Remarks"));
    o.setSKU(DOMHelper.getSubElementVauleByName(personlement, "typy_SKU"));

    o.setProvince(DOMHelper.getSubElementVauleByName(personlement, "address_province"));
    o.setCity(DOMHelper.getSubElementVauleByName(personlement, "address_city"));
    o.setAddress(DOMHelper.getSubElementVauleByName(personlement, "address_more"));
    o.setZipCode("00000000");

    NodeList ordernodes = orderinfoelement.getElementsByTagName("order");

    Element orderelement = (Element) ordernodes.item(0);

    o.setOrderId(DOMHelper.getSubElementVauleByName(orderelement, "orderId"));
    o.setMoney(DOMHelper.getSubElementVauleByName(orderelement, "order_money"));
    o.setCreatTime(
        Formatter.format(
            new Date(
                Long.valueOf(DOMHelper.getSubElementVauleByName(orderelement, "order_creattime"))),
            Formatter.DATE_TIME_FORMAT));

    o.setPaymentTime(
        Formatter.format(
            new Date(
                Long.valueOf(
                    DOMHelper.getSubElementVauleByName(orderelement, "order_paymenttime"))),
            Formatter.DATE_TIME_FORMAT));
    o.setPostage(DOMHelper.getSubElementVauleByName(orderelement, "postage"));
    o.setBuyNum(DOMHelper.getSubElementVauleByName(orderelement, "buyNUM"));
    o.setStatus(DOMHelper.getSubElementVauleByName(orderelement, "order_status"));
    return o;
  }