use of gov.ca.cwds.cals.service.dto.FacilityInspectionDTO in project cals-api by ca-cwds.
the class FacilityInspectionCollectionService method find.
@Override
public Response find(Serializable facilityId) {
Response res = null;
final FacilityInspectionsDTO dto = new FacilityInspectionsDTO();
List<Rr809Dn> deficiencies = inspectionDao.findDeficienciesByFacilityNumber(String.valueOf(facilityId));
final List<FacilityInspectionDTO> inspections = new ArrayList<>();
deficiencies.forEach(def -> inspections.add(facilityInspectionMapper.toFacilityInspectionDto(def)));
if (!inspections.isEmpty()) {
dto.setInspections(inspections);
res = dto;
}
return res;
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionDTO in project cals-api by ca-cwds.
the class FacilityInspectionsTest method getInspectionResponseTest.
@Test
public void getInspectionResponseTest() throws Exception {
WebTarget target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS + "/" + INSPECTION_ID);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
FacilityInspectionDTO inspectionDTO = invocation.get(FacilityInspectionDTO.class);
String fixture = fixture(INSPECTION_RESPONSE_JSON);
assertEqualsResponse(fixture, transformDTOtoJSON(inspectionDTO));
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionDTO in project cals-api by ca-cwds.
the class FacilityInspectionsTest method getAllFacilityInspectionsTest.
@Test
public void getAllFacilityInspectionsTest() throws JsonProcessingException {
WebTarget target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS);
Invocation.Builder invocation = target.request(MediaType.APPLICATION_JSON);
FacilityInspectionsDTO inspectionsDTO = invocation.get(FacilityInspectionsDTO.class);
assertTrue(inspectionsDTO != null);
assertTrue(inspectionsDTO.getInspections() != null);
assertTrue(inspectionsDTO.getInspections().size() == 1);
FacilityInspectionDTO inspectionDTO0 = inspectionsDTO.getInspections().get(0);
String inspectionId = inspectionDTO0.getId();
target = clientTestRule.target(FACILITIES + "/" + FACILITY_NUMBER + "/" + Constants.API.INSPECTIONS + "/" + INSPECTION_ID);
invocation = target.request(MediaType.APPLICATION_JSON);
final FacilityInspectionDTO inspectionDTO = invocation.get(FacilityInspectionDTO.class);
// Expected only 1 deficiency object
assertTrue(inspectionDTO.getDeficiencies().size() == 2);
inspectionsDTO.getInspections().forEach(inspection -> {
if (INSPECTION_ID.equals(inspection.getId())) {
assertEquals(inspection, inspectionDTO);
}
});
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionDTO in project cals-api by ca-cwds.
the class FacilityService method loadFacilityFromCwsCms.
private FacilityDTO loadFacilityFromCwsCms(FacilityParameterObject parameterObject) {
FacilityDTO facilityDto = cwsFacilityService.loadFacilityFromCwsCms(parameterObject);
if (parameterObject.isExpanded()) {
List<FacilityChildDTO> facilityChildren = cwsFacilityService.findFacilityChildrenByFacilityId(parameterObject.getFacilityId());
List<FacilityInspectionDTO> inspections = fasFacilityService.findInspectionsByFacilityId(facilityDto.getLicenseNumber());
List<ComplaintDTO> complaints = fasFacilityService.findComplaintsByFacilityId(facilityDto.getLicenseNumber());
facilityDto = facilityMapper.toExpandedFacilityDTO(facilityDto, facilityChildren, inspections, complaints);
}
return facilityDto;
}
use of gov.ca.cwds.cals.service.dto.FacilityInspectionDTO in project cals-api by ca-cwds.
the class FacilityService method loadFacilityFromLis.
private FacilityDTO loadFacilityFromLis(FacilityParameterObject parameterObject) {
FacilityDTO facilityDto = lisFacilityService.loadFacilityFromLis(parameterObject);
FacilityInformation facilityInformation = fasFacilityService.findFacilityInfoByLicenseNumber(parameterObject);
if (facilityInformation != null) {
lisFacilityService.attachVisitsData(facilityInformation);
}
fasFacilityMapper.toFacilityDTO(facilityDto, facilityInformation);
if (parameterObject.isExpanded()) {
List<FacilityChildDTO> facilityChildren = cwsFacilityService.findFacilityChildrenByLicenseNumber(Integer.valueOf(parameterObject.getFacilityId()));
List<FacilityInspectionDTO> inspections = fasFacilityService.findInspectionsByFacilityId(parameterObject.getFacilityId());
List<ComplaintDTO> complaints = fasFacilityService.findComplaintsByFacilityId(parameterObject.getFacilityId());
facilityDto = facilityMapper.toExpandedFacilityDTO(facilityDto, facilityChildren, inspections, complaints);
}
return facilityDto;
}
Aggregations