package io.reactivesw.order.cart.application.model.mapper;

import io.reactivesw.order.cart.application.model.LineItemDraft;
import io.reactivesw.order.cart.domain.entity.value.LineItemValue;

/**
 * Created by umasuo on 16/12/5.
 */
public class LineItemMapper {

  /**
   * convert model to entity.
   *
   * @param model LineItemDraft
   * @return LineItemValue
   */
  public static LineItemValue modelToEntity(LineItemDraft model) {
    LineItemValue entity = null;
    if (model != null) {
      entity = new LineItemValue();
      entity.setProductId(model.getProductId());

      entity.setQuantity(model.getQuantity());

      entity.setVariant(model.getVariantId());

      entity.setSupplyChannel(model.getSupplyChannel().getId());

      entity.setDistributionChannel(model.getDistributionChannel().getId());
    }

    return entity;
  }

}

@@ -681,32 +681,73 @@
     
-entity.setSupplyChannel(
+String supplyChannel = model.getSupplyChannel() == null ? null : 
 mode
@@ -766,24 +766,35 @@
 hannel()
+%0A          
 .getId()
 );%0A%0A    
@@ -781,27 +781,25 @@
     .getId()
-);%0A
+;
 %0A      entit
@@ -807,66 +807,228 @@
 .set
-DistributionChannel(model.getDistributionChannel().getId()
+SupplyChannel(supplyChannel);%0A%0A      String distributionChannel = model.getDistributionChannel() == null ? null : model%0A          .getDistributionChannel().getId();%0A      entity.setDistributionChannel(distributionChannel
 );%0A 

fix bug