package com.eactive.eai.rms.common.acl.monitoringCode;

import org.mapstruct.BeanMapping;
import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.ReportingPolicy;

import com.eactive.apim.portal.monitoringcode.entity.MonitoringCodeGroup;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.common.acl.monitoringCode.UI.MonitoringCodeGroupUI;

@Mapper(componentModel = "spring", uses = { MonitoringCodeMapper.class }, unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface MonitoringCodeGroupMapper extends GenericMapper<MonitoringCodeGroupUI, MonitoringCodeGroup> {

	@Mapping(source = "codeGroup", target = "cdGroup")
	@Mapping(source = "description", target = "cdGroupDesc")
	@Mapping(expression = "java(entity.getMonitoringCodes().size())", target = "childCnt")
	MonitoringCodeGroupUI toVo(MonitoringCodeGroup entity);

	@Override
	@InheritInverseConfiguration
	MonitoringCodeGroup toEntity(MonitoringCodeGroupUI vo);

	@InheritInverseConfiguration
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateToEntity(MonitoringCodeGroupUI monitoringCodeGroupUI, @MappingTarget MonitoringCodeGroup monitoringCodeGroup);

}