Skip to content

Commit

Permalink
[VAS-1146] feat: Add primitiveVersion mapping to mapper Canali-Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
svariant committed Jul 9, 2024
1 parent 8664b76 commit e54d3b5
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
import it.gov.pagopa.apiconfig.core.model.psp.Channel;
import it.gov.pagopa.apiconfig.core.util.CommonUtil;
import it.gov.pagopa.apiconfig.starter.entity.Canali;

import javax.validation.Valid;

import lombok.extern.slf4j.Slf4j;
import org.modelmapper.Converter;
import org.modelmapper.spi.MappingContext;

@Slf4j
public class ConvertCanaliToChannel implements Converter<Canali, Channel> {

@Override
public Channel convert(MappingContext<Canali, Channel> context) {
@Valid Canali source = context.getSource();
log.debug(source.toString());
return Channel.builder()
.channelCode(source.getIdCanale())
.enabled(source.getEnabled())
.brokerDescription(
CommonUtil.deNull(source.getFkIntermediarioPsp().getCodiceIntermediario()))
.build();
}
@Override
public Channel convert(MappingContext<Canali, Channel> context) {
@Valid Canali source = context.getSource();
log.debug(source.toString());
return Channel.builder()
.channelCode(source.getIdCanale())
.enabled(source.getEnabled())
.primitiveVersion(source.getFkCanaliNodo() != null ? source.getFkCanaliNodo().getVersionePrimitive() : null)
.brokerDescription(
CommonUtil.deNull(source.getFkIntermediarioPsp().getCodiceIntermediario()))
.build();
}
}

0 comments on commit e54d3b5

Please sign in to comment.