Search in sources :

Example 1 with FACatchSummaryDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchReportServiceBeanTest method testGetCatchSummaryReport.

@Test
@SneakyThrows
public void testGetCatchSummaryReport() throws ServiceException {
    FishingActivityQuery query = new FishingActivityQuery();
    List<GroupCriteria> groupByFields = new ArrayList<>();
    groupByFields.add(GroupCriteria.DATE_DAY);
    groupByFields.add(GroupCriteria.FAO_AREA);
    groupByFields.add(GroupCriteria.TERRITORY);
    groupByFields.add(GroupCriteria.EFFORT_ZONE);
    groupByFields.add(GroupCriteria.GFCM_GSA);
    groupByFields.add(GroupCriteria.GFCM_STAT_RECTANGLE);
    groupByFields.add(GroupCriteria.ICES_STAT_RECTANGLE);
    groupByFields.add(GroupCriteria.RFMO);
    groupByFields.add(GroupCriteria.SPECIES);
    query.setGroupByFields(groupByFields);
    Map<SearchFilter, String> searchCriteriaMap = new EnumMap<SearchFilter, String>(SearchFilter.class);
    searchCriteriaMap.put(SearchFilter.TRIP_ID, "NOR-TRP-20160517234053706");
    query.setSearchCriteriaMap(searchCriteriaMap);
    Map<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> groupedData = MapperUtil.getGroupedFaCatchSummaryCustomEntityData();
    when((faCatchDao).getGroupedFaCatchData(any(FishingActivityQuery.class), any(Boolean.class))).thenReturn(groupedData);
    // when(faCatchDao.getGroupedFaCatchData(query,true)).thenReturn(MapperUtil.getGroupedFaCatchSummaryCustomEntityData());
    // when(vesselIdentifiersDao.getLatestVesselIdByTrip("NOR-TRP-20160517234053706")).thenReturn(MapperUtil.getVesselIdentifiersList());
    // Trigger
    FACatchSummaryDTO fACatchSummaryDTO = faCatchReportService.getCatchSummaryReport(query, false);
    Mockito.verify(faCatchDao, Mockito.times(1)).getGroupedFaCatchData(Mockito.any(FishingActivityQuery.class), Mockito.any(Boolean.class));
    // Verify
    assertNotNull(fACatchSummaryDTO);
}
Also used : ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) GroupCriteria(eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) FaCatchSummaryCustomProxy(eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy) FACatchSummaryDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 2 with FACatchSummaryDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchReportServiceBean method getFACatchSummaryReportResponse.

/**
 * This method is used to create Catch Details page from Run Report.
 * So, To display summary  of catches, we need to consider all fishing Activity filters as well as aggregation factors specified by user .
 * Aggregation factors could be dynamically selected by user like veesel,period,area etc.
 * @param query
 * @return
 * @throws ServiceException
 */
@Override
public FACatchSummaryReportResponse getFACatchSummaryReportResponse(FishingActivityQuery query) throws ServiceException {
    log.debug("FACatchSummaryReportResponse creation starts");
    // get processed information in the form of DTO
    FACatchSummaryDTO faCatchSummaryDTO = getCatchSummaryReport(query, false);
    log.debug("FACatchSummaryDTO created");
    // We can not transfter DTO as it is over JMS because of JAVA maps.so, Map DTO to the type transferrable over JMS
    FACatchSummaryHelper faCatchSummaryHelper = FACatchSummaryHelperFactory.getFACatchSummaryHelper(FACatchSummaryHelperFactory.STANDARD);
    // Create response object for JMS
    FACatchSummaryReportResponse faCatchSummaryReportResponse = new FACatchSummaryReportResponse();
    faCatchSummaryReportResponse.setSummaryRecords(faCatchSummaryHelper.buildFACatchSummaryRecordList(faCatchSummaryDTO.getRecordDTOs()));
    faCatchSummaryReportResponse.setTotal(FACatchSummaryMapper.INSTANCE.mapToSummaryTable(faCatchSummaryDTO.getTotal()));
    log.debug("SummaryTable XML Schema response---->" + FACatchSummaryHelper.printJsonstructure(faCatchSummaryReportResponse));
    return faCatchSummaryReportResponse;
}
Also used : FACatchSummaryHelper(eu.europa.ec.fisheries.ers.service.facatch.FACatchSummaryHelper) FACatchSummaryDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO) FACatchSummaryReportResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportResponse)

Example 3 with FACatchSummaryDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchReportServiceBean method getCatchSummaryReport.

/**
 *  This method groups FACatch Data, performs business logic to create summary report
 *  and creates FacatchSummaryDTO object as expected by web interface.
 *  isReporting : TRUE indicates that the method should be used to generate result for REPORTING module
 *                FALSE indicates that the method should be used to generate result from TRIP SUMMARY VIEW
 * @param query
 * @return
 * @throws ServiceException
 */
@Override
public FACatchSummaryDTO getCatchSummaryReport(FishingActivityQuery query, boolean isLanding) throws ServiceException {
    // get grouped data
    Map<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> groupedData = faCatchDao.getGroupedFaCatchData(query, isLanding);
    // post process data to create Summary table part of Catch summary Report
    FACatchSummaryHelper faCatchSummaryHelper = isLanding ? FACatchSummaryHelperFactory.getFACatchSummaryHelper(FACatchSummaryHelperFactory.PRESENTATION) : FACatchSummaryHelperFactory.getFACatchSummaryHelper(FACatchSummaryHelperFactory.STANDARD);
    List<FACatchSummaryRecordDTO> catchSummaryList = faCatchSummaryHelper.buildFACatchSummaryRecordDTOList(groupedData);
    // Post process data to calculate Totals for each column
    SummaryTableDTO summaryTableDTOTotal = faCatchSummaryHelper.populateSummaryTableWithTotal(catchSummaryList);
    // Create DTO object to send back to the web
    FACatchSummaryDTO faCatchSummaryDTO = new FACatchSummaryDTO();
    faCatchSummaryDTO.setRecordDTOs(catchSummaryList);
    faCatchSummaryDTO.setTotal(summaryTableDTOTotal);
    return faCatchSummaryDTO;
}
Also used : FaCatchSummaryCustomProxy(eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy) FACatchSummaryHelper(eu.europa.ec.fisheries.ers.service.facatch.FACatchSummaryHelper) FACatchSummaryDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO) ArrayList(java.util.ArrayList) List(java.util.List) FACatchSummaryRecordDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO) SummaryTableDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.SummaryTableDTO)

Aggregations

FACatchSummaryDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO)3 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)2 FACatchSummaryHelper (eu.europa.ec.fisheries.ers.service.facatch.FACatchSummaryHelper)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FACatchSummaryRecordDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO)1 SummaryTableDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.SummaryTableDTO)1 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)1 FACatchSummaryReportResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryReportResponse)1 GroupCriteria (eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)1 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)1 EnumMap (java.util.EnumMap)1 SneakyThrows (lombok.SneakyThrows)1 Test (org.junit.Test)1