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);
}
}
});
}
Aggregations