use of gov.ca.cwds.data.legacy.cms.entity.syscodes.County 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);
}
}
});
}
use of gov.ca.cwds.data.legacy.cms.entity.syscodes.County in project api-core by ca-cwds.
the class CountiesDao method findAll.
@Override
public List<County> findAll() {
Session session = this.getSessionFactory().getCurrentSession();
Query<County> query = session.createNamedQuery(County.NQ_ALL, County.class);
ImmutableList.Builder<County> entities = new ImmutableList.Builder<>();
entities.addAll(query.list());
return entities.build();
}
use of gov.ca.cwds.data.legacy.cms.entity.syscodes.County in project api-core by ca-cwds.
the class CountiesDao method findByLogicalId.
public County findByLogicalId(String logicalId) {
Session session = this.getSessionFactory().getCurrentSession();
Class<County> entityClass = getEntityClass();
Query<County> query = session.createNamedQuery(entityClass.getSimpleName() + ".findByLogicalId", County.class);
query.setParameter("logicalId", logicalId);
County county = null;
try {
county = query.getSingleResult();
} catch (NoResultException e) {
LOG.warn("There is no result for logicalId = {}", logicalId);
LOG.debug(e.getMessage(), e);
}
return county;
}
use of gov.ca.cwds.data.legacy.cms.entity.syscodes.County in project cals-api by ca-cwds.
the class CountiesService method find.
@Override
public Response find(Serializable serializable) {
final CountiesDTO countiesDTO = new CountiesDTO();
List<County> counties = countiesDao.findAll();
counties.forEach((County county) -> countiesDTO.getCounties().add(countyMapper.toCountyDTO(county)));
return countiesDTO;
}
Aggregations