Search in sources :

Example 1 with County

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

Example 2 with County

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) County(gov.ca.cwds.data.legacy.cms.entity.syscodes.County) Session(org.hibernate.Session)

Example 3 with County

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;
}
Also used : NoResultException(javax.persistence.NoResultException) County(gov.ca.cwds.data.legacy.cms.entity.syscodes.County) Session(org.hibernate.Session)

Example 4 with 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;
}
Also used : CountiesDTO(gov.ca.cwds.cals.service.dto.CountiesDTO) County(gov.ca.cwds.data.legacy.cms.entity.syscodes.County)

Aggregations

County (gov.ca.cwds.data.legacy.cms.entity.syscodes.County)4 Session (org.hibernate.Session)2 ImmutableList (com.google.common.collect.ImmutableList)1 CountiesDTO (gov.ca.cwds.cals.service.dto.CountiesDTO)1 BaseOutOfHomePlacement (gov.ca.cwds.data.legacy.cms.entity.BaseOutOfHomePlacement)1 BasePlacementEpisode (gov.ca.cwds.data.legacy.cms.entity.BasePlacementEpisode)1 NoResultException (javax.persistence.NoResultException)1 AfterMapping (org.mapstruct.AfterMapping)1