Search in sources :

Example 1 with FacilityInspectionDTO

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;
}
Also used : Response(gov.ca.cwds.rest.api.Response) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) Rr809Dn(gov.ca.cwds.cals.persistence.model.fas.Rr809Dn) ArrayList(java.util.ArrayList) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)

Example 2 with FacilityInspectionDTO

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));
}
Also used : Invocation(javax.ws.rs.client.Invocation) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) WebTarget(javax.ws.rs.client.WebTarget) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Example 3 with FacilityInspectionDTO

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);
        }
    });
}
Also used : Invocation(javax.ws.rs.client.Invocation) FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) WebTarget(javax.ws.rs.client.WebTarget) FacilityInspectionsDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO) Test(org.junit.Test) BaseCalsApiIntegrationTest(gov.ca.cwds.cals.BaseCalsApiIntegrationTest)

Example 4 with FacilityInspectionDTO

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;
}
Also used : FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) FacilityDTO(gov.ca.cwds.cals.service.dto.FacilityDTO) FacilityChildDTO(gov.ca.cwds.cals.service.dto.FacilityChildDTO) ComplaintDTO(gov.ca.cwds.cals.service.dto.ComplaintDTO)

Example 5 with FacilityInspectionDTO

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;
}
Also used : FacilityInspectionDTO(gov.ca.cwds.cals.service.dto.FacilityInspectionDTO) FacilityInformation(gov.ca.cwds.cals.persistence.model.fas.FacilityInformation) FacilityDTO(gov.ca.cwds.cals.service.dto.FacilityDTO) FacilityChildDTO(gov.ca.cwds.cals.service.dto.FacilityChildDTO) ComplaintDTO(gov.ca.cwds.cals.service.dto.ComplaintDTO)

Aggregations

FacilityInspectionDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionDTO)5 BaseCalsApiIntegrationTest (gov.ca.cwds.cals.BaseCalsApiIntegrationTest)2 ComplaintDTO (gov.ca.cwds.cals.service.dto.ComplaintDTO)2 FacilityChildDTO (gov.ca.cwds.cals.service.dto.FacilityChildDTO)2 FacilityDTO (gov.ca.cwds.cals.service.dto.FacilityDTO)2 FacilityInspectionsDTO (gov.ca.cwds.cals.service.dto.FacilityInspectionsDTO)2 Invocation (javax.ws.rs.client.Invocation)2 WebTarget (javax.ws.rs.client.WebTarget)2 Test (org.junit.Test)2 FacilityInformation (gov.ca.cwds.cals.persistence.model.fas.FacilityInformation)1 Rr809Dn (gov.ca.cwds.cals.persistence.model.fas.Rr809Dn)1 Response (gov.ca.cwds.rest.api.Response)1 ArrayList (java.util.ArrayList)1