package com.eactive.eai.rms.onl.manage.rule.layout.mapper;

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

import com.eactive.eai.data.entity.onl.transformer.layout.LayoutEntity;
import com.eactive.eai.data.mapper.BaseMapperConfig;
import com.eactive.eai.data.mapper.GenericMapper;
import com.eactive.eai.rms.onl.manage.rule.layout.ui.LayoutUI;

@Mapper(config = BaseMapperConfig.class, uses = { LayoutItemUIMapper.class })
public interface LayoutUIMapper extends GenericMapper<LayoutUI, LayoutEntity> {

	@Mapping(source = "loutname", target = "loutName")
	@Mapping(source = "loutptrnname", target = "loutPtrnName")
	@Mapping(source = "loutdesc", target = "loutDesc")
	@Mapping(source = "lastamndhms", target = "lastamndhms", dateFormat = "yyyyMMddHHmmssSS")
	@Mapping(source = "eaibzwkdstcd", target = "eaiBzwkDstcd")
	@Mapping(source = "uapplname", target = "uapplname")
	@Mapping(source = "sysintfacname", target = "sysintfacname")
	@Mapping(source = "author", target = "author")
	@Mapping(source = "eaisevrdstcd", target = "eaiSevrDstcd")
	@Mapping(source = "modfimgtstusdstcd", target = "modfimgtstusdstcd")
	@Mapping(source = "useyn", target = "useYn")
	@Mapping(source = "verinfo", target = "verInfo")
	@Mapping(source = "layoutItemEntities", target = "layoutItems")
	@Override
	LayoutUI toVo(LayoutEntity entity);

	@InheritInverseConfiguration(name = "toVo")
	@Override
	LayoutEntity toEntity(LayoutUI vo);

	@InheritInverseConfiguration(name = "toVo")
	@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
	void updateEntity(LayoutUI layoutUI, @MappingTarget LayoutEntity layoutEntity);

	@Mapping(target = "layoutItems", ignore = true)
	@InheritConfiguration
	LayoutUI toVoWithoutChild(LayoutEntity entity);
	
}
