TransportUnitMapperImpl.java
package org.openwms.common.transport;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.openwms.common.location.LocationMapper;
import org.openwms.common.transport.api.TransportUnitVO;
import org.openwms.common.transport.api.messages.TransportUnitMO;
import org.openwms.common.transport.barcode.Barcode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Generated(
value = "org.mapstruct.ap.MappingProcessor"
)
@Component
public class TransportUnitMapperImpl extends TransportUnitMapper {
private final LocationMapper locationMapper;
private final TransportUnitTypeMapper transportUnitTypeMapper;
@Autowired
public TransportUnitMapperImpl(LocationMapper locationMapper, TransportUnitTypeMapper transportUnitTypeMapper) {
this.locationMapper = locationMapper;
this.transportUnitTypeMapper = transportUnitTypeMapper;
}
@Override
public void copy(TransportUnit source, TransportUnit target) {
if ( source == null ) {
return;
}
if ( source.getInventoryDate() != null ) {
target.setInventoryDate( source.getInventoryDate() );
}
if ( source.hasPersistentKey() ) {
target.setPersistentKey( source.getPersistentKey() );
}
else {
target.setPersistentKey( null );
}
target.setActualLocation( source.getActualLocation() );
target.setTargetLocation( source.getTargetLocation() );
target.setEmpty( source.getEmpty() );
target.setGroupName( source.getGroupName() );
target.setInventoryUser( source.getInventoryUser() );
target.setWeight( source.getWeight() );
target.setState( source.getState() );
target.setTransportUnitType( source.getTransportUnitType() );
if ( target.getErrors() != null ) {
target.getErrors().clear();
List<UnitError> list = source.getErrors();
if ( list != null ) {
target.getErrors().addAll( list );
}
}
if ( target.getChildren() != null ) {
target.getChildren().clear();
if ( source.hasChildren() ) {
target.getChildren().addAll( source.getChildren() );
}
}
}
@Override
public TransportUnit convert(TransportUnitVO vo) {
if ( vo == null ) {
return null;
}
Barcode barcode = barcodeGenerator.convert(vo.getBarcode());
TransportUnit transportUnit = new TransportUnit( barcode );
transportUnit.setPersistentKey( vo.getpKey() );
transportUnit.setActualLocation( locationMapper.convertVO( vo.getActualLocation() ) );
transportUnit.setTargetLocation( locationMapper.convertVO( vo.getTargetLocation() ) );
transportUnit.setWeight( vo.getWeight() );
transportUnit.setState( vo.getState() );
transportUnit.setTransportUnitType( transportUnitTypeMapper.convert( vo.getTransportUnitType() ) );
return transportUnit;
}
@Override
public TransportUnitVO convertToVO(TransportUnit eo) {
if ( eo == null ) {
return null;
}
TransportUnitVO transportUnitVO = new TransportUnitVO();
if ( eo.hasPersistentKey() ) {
transportUnitVO.setpKey( eo.getPersistentKey() );
}
transportUnitVO.setBarcode( eoBarcodeValue( eo ) );
transportUnitVO.setTransportUnitType( transportUnitTypeMapper.convertToVO( transportUnitTypeMapper.convert( eoTransportUnitTypeType( eo ) ) ) );
transportUnitVO.setCreateDt( eo.getCreateDt() );
transportUnitVO.setOl( eo.getOl() );
transportUnitVO.setLastModifiedDt( eo.getLastModifiedDt() );
transportUnitVO.setActualLocation( locationMapper.convertToVO( eo.getActualLocation() ) );
transportUnitVO.setTargetLocation( locationMapper.convertToVO( eo.getTargetLocation() ) );
transportUnitVO.setState( eo.getState() );
transportUnitVO.setWeight( eo.getWeight() );
transportUnitVO.setActualLocationDate( eo.getActualLocationDate() );
return transportUnitVO;
}
@Override
public List<TransportUnitVO> convertToVO(List<TransportUnit> eo) {
if ( eo == null ) {
return null;
}
List<TransportUnitVO> list = new ArrayList<TransportUnitVO>( eo.size() );
for ( TransportUnit transportUnit : eo ) {
list.add( convertToVO( transportUnit ) );
}
return list;
}
@Override
public TransportUnitMO convertToMO(TransportUnit eo) {
if ( eo == null ) {
return null;
}
TransportUnitMO transportUnitMO = new TransportUnitMO();
if ( eo.hasPersistentKey() ) {
transportUnitMO.setpKey( eo.getPersistentKey() );
}
transportUnitMO.setActualLocation( locationMapper.convertToMO( eo.getActualLocation() ) );
transportUnitMO.setTargetLocation( locationMapper.convertToMO( eo.getTargetLocation() ) );
transportUnitMO.setActualLocationDate( eo.getActualLocationDate() );
transportUnitMO.setState( eo.getState() );
transportUnitMO.setTransportUnitType( transportUnitTypeMapper.convertToMO( eo.getTransportUnitType() ) );
transportUnitMO.setBarcode( eo.getBarcode().getValue() );
transportUnitMO.setParent( eo.getParent() == null ? null : eo.getParent().getBarcode().getValue() );
return transportUnitMO;
}
private String eoBarcodeValue(TransportUnit transportUnit) {
if ( transportUnit == null ) {
return null;
}
Barcode barcode = transportUnit.getBarcode();
if ( barcode == null ) {
return null;
}
String value = barcode.getValue();
if ( value == null ) {
return null;
}
return value;
}
private String eoTransportUnitTypeType(TransportUnit transportUnit) {
if ( transportUnit == null ) {
return null;
}
TransportUnitType transportUnitType = transportUnit.getTransportUnitType();
if ( transportUnitType == null ) {
return null;
}
String type = transportUnitType.getType();
if ( type == null ) {
return null;
}
return type;
}
}