All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openwms.common.location.LocationGroupMapperImpl Maven / Gradle / Ivy

Go to download

Essential services on common resources like Locations, LocationGroups and TransportUnits

There is a newer version: 2.0.0
Show newest version
package org.openwms.common.location;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;
import org.openwms.common.account.Account;
import org.openwms.common.location.api.LocationGroupVO;
import org.openwms.common.location.api.messages.LocationGroupMO;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor"
)
@Component
public class LocationGroupMapperImpl extends LocationGroupMapper {

    @Override
    public LocationGroupVO convertToVO(LocationGroup eo) {
        if ( eo == null ) {
            return null;
        }

        LocationGroupVO locationGroupVO = new LocationGroupVO();

        locationGroupVO.setpKey( eo.getPersistentKey() );
        locationGroupVO.setAccountId( eoAccountIdentifier( eo ) );
        if ( eo.hasParent() ) {
            locationGroupVO.setParent( eoParentName( eo ) );
        }
        locationGroupVO.setGroupStateIn( eo.getGroupStateIn() );
        locationGroupVO.setGroupStateOut( eo.getGroupStateOut() );
        locationGroupVO.setOperationMode( eo.getOperationMode() );
        locationGroupVO.setName( eo.getName() );
        locationGroupVO.setGroupType( eo.getGroupType() );

        return locationGroupVO;
    }

    @Override
    public LocationGroupMO convertToMO(LocationGroup eo) {
        if ( eo == null ) {
            return null;
        }

        LocationGroupMO locationGroupMO = new LocationGroupMO();

        locationGroupMO.setAccountId( eoAccountIdentifier( eo ) );
        if ( eo.hasParent() ) {
            locationGroupMO.setParent( eoParentName( eo ) );
        }
        locationGroupMO.setOperationMode( eo.getOperationMode() );
        locationGroupMO.setName( eo.getName() );

        locationGroupMO.setIncomingActive( eo.isInfeedAllowed() );
        locationGroupMO.setOutgoingActive( eo.isOutfeedAllowed() );

        return locationGroupMO;
    }

    @Override
    public List convertToVO(List eo) {
        if ( eo == null ) {
            return null;
        }

        List list = new ArrayList( eo.size() );
        for ( LocationGroup locationGroup : eo ) {
            list.add( convertToVO( locationGroup ) );
        }

        return list;
    }

    private String eoAccountIdentifier(LocationGroup locationGroup) {
        if ( locationGroup == null ) {
            return null;
        }
        Account account = locationGroup.getAccount();
        if ( account == null ) {
            return null;
        }
        String identifier = account.getIdentifier();
        if ( identifier == null ) {
            return null;
        }
        return identifier;
    }

    private String eoParentName(LocationGroup locationGroup) {
        if ( locationGroup == null ) {
            return null;
        }
        if ( !locationGroup.hasParent() ) {
            return null;
        }
        LocationGroup parent = locationGroup.getParent();
        String name = parent.getName();
        if ( name == null ) {
            return null;
        }
        return name;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy