Search in sources :

Example 1 with BasePlacementEpisode

use of gov.ca.cwds.data.legacy.cms.entity.BasePlacementEpisode in project cals-api by ca-cwds.

the class FacilityChildMapper method after.

@AfterMapping
default void after(@MappingTarget FacilityChildDTO facilityChildDto, Client client) {
    Optional.ofNullable(client).ifPresent(c -> {
        Set<? extends BasePlacementEpisode> placementEpisodes = c.getPlacementEpisodes();
        if (!placementEpisodes.isEmpty()) {
            FacilityChildMapper facilityChildMapper = Mappers.getMapper(FacilityChildMapper.class);
            BasePlacementEpisode placementEpisode = placementEpisodes.iterator().next();
            County county = placementEpisode.getCounty();
            facilityChildMapper.toFacilityChildDTO(facilityChildDto, county);
            Set<? extends BaseOutOfHomePlacement> outOfHomePlacements = placementEpisode.getOutOfHomePlacements();
            if (!outOfHomePlacements.isEmpty()) {
                BaseOutOfHomePlacement outOfHomePlacement = outOfHomePlacements.iterator().next();
                facilityChildMapper.toFacilityChildDTO(facilityChildDto, outOfHomePlacement);
            }
        }
    });
}
Also used : BaseOutOfHomePlacement(gov.ca.cwds.data.legacy.cms.entity.BaseOutOfHomePlacement) BasePlacementEpisode(gov.ca.cwds.data.legacy.cms.entity.BasePlacementEpisode) County(gov.ca.cwds.data.legacy.cms.entity.syscodes.County) AfterMapping(org.mapstruct.AfterMapping)

Aggregations

BaseOutOfHomePlacement (gov.ca.cwds.data.legacy.cms.entity.BaseOutOfHomePlacement)1 BasePlacementEpisode (gov.ca.cwds.data.legacy.cms.entity.BasePlacementEpisode)1 County (gov.ca.cwds.data.legacy.cms.entity.syscodes.County)1 AfterMapping (org.mapstruct.AfterMapping)1