Package org.company.recordshop.domain

Examples of org.company.recordshop.domain.OrderLine


  /**
   * {@inheritDoc}
   */
  public OrderLineDto readOrderLine(Long id) {
    OrderLine result = customerServiceModelDomainService.readOrderLine(id);
    return (result == null) ? null : orderLineDtoTranslator.toDto(result);
  }
View Full Code Here


   * {@inheritDoc}
   */
  public void addToOrderLines(OrderDto whole, OrderLineDto part) {
    Assert.notNull(whole, "argument [whole] may not be null");
    Assert.notNull(part, "argument [part] may not be null");
    OrderLine partBusinessObject = customerServiceModelDomainService
        .readOrderLine(part.getId());
    Order mainBusinessObject = customerServiceModelDomainService
        .readOrder(whole.getId());
    customerServiceModelDomainService.addToOrderLines(mainBusinessObject,
        partBusinessObject);
View Full Code Here

   * {@inheritDoc}
   */
  public void removeFromOrderLines(OrderDto whole, OrderLineDto part) {
    Assert.notNull(whole, "argument [whole] may not be null");
    Assert.notNull(part, "argument [part] may not be null");
    OrderLine partObject = customerServiceModelDomainService
        .readOrderLine(part.getId());
    Order wholeObject = customerServiceModelDomainService.readOrder(whole
        .getId());
    customerServiceModelDomainService.removeFromOrderLines(wholeObject,
        partObject);
View Full Code Here

    Assert.notNull(source, "argument [source] may not be null");
    Assert.isNull(source.getId(),
        "Can not translate a dto with existing id to a new domain object. Dto: "
            + source);
    OrderLine target = new OrderLine(source.getLineNumber(), source
        .getDescription()

    );
    return fromDto(source, target, translated);
View Full Code Here

    Assert.notNull(source, "argument [source] may not be null");
    Assert.isNull(source.getId(),
        "Can not translate a dto with existing id to a new domain object. Dto: "
            + source);
    OrderLine target = new OrderLine(source.getLineNumber(), source
        .getDescription()

    );
    return fromDto(source, target, translated);
View Full Code Here

  @Test
  public void testAddAndRetrieve() {
      
      Product product = new Product("PRODNR-1234", 99.99f, true);
       
        OrderLine orderLine = new OrderLine(1, "ORDERLINE-1");
        orderLine.setProduct(product);
       
        orderLineDao.add(orderLine);
        flush();
        clear();

        OrderLine saved = orderLineDao.retrieve(orderLine.getId());
        assertTrue(saved.getProduct().getId() > 0);
        assertEquals("PRODNR-1234", saved.getProduct().getProductNumber());
    }
View Full Code Here

      } else {

        /* An existing object to be updated */
        if (target.getFromOrderLines(element.getId()) == null) {
          // Element is not in target yet, read it from the store and add to target
          OrderLine original = orderLineDao.retrieve(element.getId());
          OrderLine updated = orderLineDtoTranslator.fromDto(element,
              original, translated);
          target.addToOrderLines(updated);
        } else {
          // Element is in target already, use this object. No need to add to the collection
          orderLineDtoTranslator.fromDto(element, target
View Full Code Here

    @Test
    public void testAddWithOrders() {
        Customer customer = new Customer("Johannes", "Vermeer", date(), 2);

        Order order = new Order("AA111");
        order.addToOrderLines(new OrderLine(1, "verf"));
        order.addToOrderLines(new OrderLine(2, "kwast"));
        order.addToOrderLines(new OrderLine(3, "doek"));
        customer.addToOrders(order);

        order = new Order("AA222");
        order.addToOrderLines(new OrderLine(7, "rood"));
        order.addToOrderLines(new OrderLine(8, "penseel"));
        order.addToOrderLines(new OrderLine(9, "ezel"));
        customer.addToOrders(order);

        customerDao.add(customer);
        flush();
View Full Code Here

  @Test
  public final void testUpdateOrderLineQauntity() {
   
    Product product = new Product("1234", 1F, true);
    product.setMinimalQuantity(2);
    OrderLine orderline = new OrderLine(1, "Test line");
    orderline.setQuantity(1);
    try {
      orderline.setProduct(product);
      fail("A BusinessRuleException should be thrown");
    } catch (BusinessRuleException bre) {
      assertTrue( bre.getMessage().contains("orderline.invalid.quantity"));
    }   
   
View Full Code Here

     * Validates if the quantity for the OrderLine matches the minimal quantity of the associated Product.
     */
    public void validate(Object target, Errors errors) {

        // CheckProductMinimumQuantity.
        OrderLine orderline = (OrderLine) target;

        if (orderline.getProduct() != null) {

            if (orderline.getQuantity() < orderline.getProduct().getMinimalQuantity()) {
                errors.rejectValue("quantity", "orderline.invalid.quantity", null,
                        "The minimal quantity for this Product is:" + orderline.getProduct().getMinimalQuantity());
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.company.recordshop.domain.OrderLine

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.