package com.oguerreiro.resilient.service.mapper;

import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import com.oguerreiro.resilient.domain.InputDataUpload;
import com.oguerreiro.resilient.domain.Organization;
import com.oguerreiro.resilient.domain.Period;
import com.oguerreiro.resilient.service.dto.InputDataUploadDTO;
import com.oguerreiro.resilient.service.dto.OrganizationDTO;
import com.oguerreiro.resilient.service.dto.PeriodDTO;

/**
 * Mapper for the entity {@link InputDataUpload} and its DTO
 * {@link InputDataUploadDTO}.
 */
@Mapper(componentModel = "spring")
public interface InputDataUploadMapper extends ResilientEntityMapper<InputDataUploadDTO, InputDataUpload> {
  @Mapping(target = "period", source = "period", qualifiedByName = "periodName")
  @Mapping(target = "owner", source = "owner", qualifiedByName = "organizationName")
  InputDataUploadDTO toDto(InputDataUpload s);

  @Named("periodName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "name", source = "name")
  PeriodDTO toDtoPeriodName(Period period);

  @Named("organizationName")
  @BeanMapping(ignoreByDefault = true)
  @Mapping(target = "id", source = "id")
  @Mapping(target = "name", source = "name")
  OrganizationDTO toDtoOrganizationName(Organization organization);
}
