Search in sources :

Example 1 with FACatchSummaryRecordDTO

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

the class FACatchSummaryPresentationHelper method buildFACatchSummaryRecordDTOList.

/**
 *  Post process data received from database to create FACatchSummaryRecordDTO. Every record will have summary calculated for it.
 *
 * @param groupedMap
 * @return List<FACatchSummaryRecordDTO> Processed records having summary data
 */
@Override
public List<FACatchSummaryRecordDTO> buildFACatchSummaryRecordDTOList(Map<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> groupedMap) {
    List<FACatchSummaryRecordDTO> faCatchSummaryRecordDTOs = new ArrayList<>();
    for (Map.Entry<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> entry : groupedMap.entrySet()) {
        FaCatchSummaryCustomProxy customEntity = entry.getKey();
        // We dont want Presentation to be part of group criteria. We want to display this information in summmary table so, remove it
        customEntity.setPresentation(null);
        FACatchSummaryRecordDTO faCatchSummaryDTO = FACatchSummaryMapper.INSTANCE.mapToFACatchSummaryRecordDTOWithPresentation(entry.getKey(), entry.getValue());
        if (CollectionUtils.isEmpty(faCatchSummaryDTO.getGroups())) {
            // Do not add record to the list if no data for grouping factors found
            log.error("No data for the grouping factors found :" + faCatchSummaryDTO);
            continue;
        }
        // If there is Group but no data for Summary table for the group, do not send it to frontend
        if (faCatchSummaryDTO.getSummaryTable() == null || (faCatchSummaryDTO.getSummaryTable().getSummaryFaCatchType() == null && faCatchSummaryDTO.getSummaryTable().getSummaryFishSize() == null)) {
            log.error("No data for the summary found :" + faCatchSummaryDTO);
            continue;
        }
        faCatchSummaryRecordDTOs.add(faCatchSummaryDTO);
    }
    return faCatchSummaryRecordDTOs;
}
Also used : FaCatchSummaryCustomProxy(eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy) ArrayList(java.util.ArrayList) FACatchSummaryRecordDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with FACatchSummaryRecordDTO

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

the class FACatchSummaryReportHelper method buildFACatchSummaryRecordDTOList.

/**
 *  Post process data received from database to create FACatchSummaryRecordDTO. Every record will have summary calculated for it.
 *
 * @param groupedMap
 * @return List<FACatchSummaryRecordDTO> Processed records having summary data
 */
@Override
public List<FACatchSummaryRecordDTO> buildFACatchSummaryRecordDTOList(Map<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> groupedMap) {
    List<FACatchSummaryRecordDTO> faCatchSummaryRecordDTOs = new ArrayList<>();
    for (Map.Entry<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> entry : groupedMap.entrySet()) {
        FACatchSummaryRecordDTO faCatchSummaryDTO = FACatchSummaryMapper.INSTANCE.mapToFACatchSummaryRecordDTO(entry.getKey(), entry.getValue());
        if (CollectionUtils.isEmpty(faCatchSummaryDTO.getGroups())) {
            // Do not add record to the list if no data for grouping factors found
            log.error("No data for the grouping factors found :" + faCatchSummaryDTO);
            continue;
        }
        // If there is Group but no data for Summary table for the group, do not send it to frontend
        if (faCatchSummaryDTO.getSummaryTable() == null || (faCatchSummaryDTO.getSummaryTable().getSummaryFaCatchType() == null && faCatchSummaryDTO.getSummaryTable().getSummaryFishSize() == null)) {
            log.error("No data for the summary found :" + faCatchSummaryDTO);
            continue;
        }
        faCatchSummaryRecordDTOs.add(faCatchSummaryDTO);
    }
    return faCatchSummaryRecordDTOs;
}
Also used : FaCatchSummaryCustomProxy(eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy) ArrayList(java.util.ArrayList) FACatchSummaryRecordDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) Map(java.util.Map)

Example 3 with FACatchSummaryRecordDTO

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

the class FACatchSummaryHelper method populateSummaryTableWithTotal.

/**
 * Creates Summary table structure for provided DTO list
 * @param catchSummaryDTOList list of records to be processed to create summary structure
 * @return
 */
public SummaryTableDTO populateSummaryTableWithTotal(List<FACatchSummaryRecordDTO> catchSummaryDTOList) {
    SummaryTableDTO summaryTableWithTotals = new SummaryTableDTO();
    for (FACatchSummaryRecordDTO faCatchSummaryDTO : catchSummaryDTOList) {
        SummaryTableDTO summaryTable = faCatchSummaryDTO.getSummaryTable();
        populateTotalFishSizeMap(summaryTableWithTotals, summaryTable);
        populateTotalFaCatchMap(summaryTableWithTotals, summaryTable);
    }
    return summaryTableWithTotals;
}
Also used : SummaryTableDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.SummaryTableDTO) FACatchSummaryRecordDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO)

Example 4 with FACatchSummaryRecordDTO

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

the class FACatchSummaryHelper method buildFACatchSummaryRecordList.

public List<FACatchSummaryRecord> buildFACatchSummaryRecordList(List<FACatchSummaryRecordDTO> catchSummaryDTOList) {
    List<FACatchSummaryRecord> faCatchSummaryRecords = new ArrayList<>();
    for (FACatchSummaryRecordDTO faCatchSummaryDTO : catchSummaryDTOList) {
        FACatchSummaryRecord faCatchSummaryRecord = new FACatchSummaryRecord();
        faCatchSummaryRecord.setGroups(faCatchSummaryDTO.getGroups());
        faCatchSummaryRecord.setSummary(FACatchSummaryMapper.INSTANCE.mapToSummaryTable(faCatchSummaryDTO.getSummaryTable()));
        faCatchSummaryRecords.add(faCatchSummaryRecord);
    }
    log.debug("List of FACatchSummaryRecord objects created");
    return faCatchSummaryRecords;
}
Also used : ArrayList(java.util.ArrayList) FACatchSummaryRecord(eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryRecord) FACatchSummaryRecordDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO)

Example 5 with FACatchSummaryRecordDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO 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

FACatchSummaryRecordDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryRecordDTO)5 ArrayList (java.util.ArrayList)4 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)3 List (java.util.List)3 SummaryTableDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.SummaryTableDTO)2 EnumMap (java.util.EnumMap)2 Map (java.util.Map)2 FACatchSummaryDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO)1 FACatchSummaryHelper (eu.europa.ec.fisheries.ers.service.facatch.FACatchSummaryHelper)1 FACatchSummaryRecord (eu.europa.ec.fisheries.uvms.activity.model.schemas.FACatchSummaryRecord)1 HashMap (java.util.HashMap)1