Search in sources :

Example 1 with FaCatchTypeEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class FACatchSummaryPresentationHelper method populateTotalFaCatchMap.

@Override
public void populateTotalFaCatchMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
    Map<FaCatchTypeEnum, Object> catchTypeEnumMapMap = summaryTable.getSummaryFaCatchType();
    if (MapUtils.isNotEmpty(catchTypeEnumMapMap)) {
        Map<FaCatchTypeEnum, Object> totalCatchTypeMap = summaryTableWithTotals.getSummaryFaCatchType();
        if (MapUtils.isEmpty(totalCatchTypeMap)) {
            totalCatchTypeMap = new EnumMap<>(FaCatchTypeEnum.class);
            summaryTableWithTotals.setSummaryFaCatchType(totalCatchTypeMap);
        }
        // Go through all the catch types and calculate total for each type
        for (Map.Entry<FaCatchTypeEnum, Object> entry : catchTypeEnumMapMap.entrySet()) {
            // key fishSize
            FaCatchTypeEnum catchType = entry.getKey();
            Object value = entry.getValue();
            if (value instanceof Map) {
                // check if already present
                Map<String, Map<String, Double>> fishSizeMap = (Map<String, Map<String, Double>>) totalCatchTypeMap.get(catchType);
                fishSizeMap = populateSpeciesPresentationMapWithTotal((Map<String, Map<String, Double>>) value, fishSizeMap);
                totalCatchTypeMap.put(catchType, fishSizeMap);
            }
        }
    }
}
Also used : FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with FaCatchTypeEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class FACatchSummaryReportHelper method populateTotalFaCatchMap.

/**
 * This method processes data to calculate weights for different Catch types
 * @param summaryTableWithTotals  Add the calculation to this final class
 * @param summaryTable process this object to calculate totals
 */
@Override
public void populateTotalFaCatchMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
    Map<FaCatchTypeEnum, Object> catchTypeEnumMapMap = summaryTable.getSummaryFaCatchType();
    if (MapUtils.isNotEmpty(catchTypeEnumMapMap)) {
        Map<FaCatchTypeEnum, Object> totalCatchTypeMap = summaryTableWithTotals.getSummaryFaCatchType();
        if (MapUtils.isEmpty(totalCatchTypeMap)) {
            totalCatchTypeMap = new EnumMap<>(FaCatchTypeEnum.class);
            summaryTableWithTotals.setSummaryFaCatchType(totalCatchTypeMap);
        }
        // Go through all the catch types and calculate total for each type
        for (Map.Entry<FaCatchTypeEnum, Object> entry : catchTypeEnumMapMap.entrySet()) {
            // key fishSize
            FaCatchTypeEnum catchType = entry.getKey();
            Object value = entry.getValue();
            if (value instanceof Map) {
                // check if already present
                Map<String, Double> resultTotalSpeciesMap = (Map<String, Double>) totalCatchTypeMap.get(catchType);
                resultTotalSpeciesMap = extractSpeciesCountMap((Map<String, Double>) value, resultTotalSpeciesMap);
                totalCatchTypeMap.put(catchType, resultTotalSpeciesMap);
            } else if (value instanceof Double) {
                totalCatchTypeMap.put(catchType, calculateTotalValue((Double) value, (Double) totalCatchTypeMap.get(catchType)));
            }
        }
    }
}
Also used : FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) EnumMap(java.util.EnumMap) Map(java.util.Map)

Example 3 with FaCatchTypeEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class ARRCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.

@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
    FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
    if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.NOTIFICATION) {
        return null;
    }
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
    for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
        FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
        boolean onboardXorUnloaded = (faCatchType == FaCatchTypeEnum.ONBOARD && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.UNLOADED)) || (faCatchType == FaCatchTypeEnum.UNLOADED && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.ONBOARD));
        if (onboardXorUnloaded) {
            handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
        }
    }
    return catchEvolutionProgressDTO;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FaReportDocumentType(eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)

Example 4 with FaCatchTypeEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class DEPCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.

@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
    FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
    if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.DECLARATION && faReportDocumentType != FaReportDocumentType.NOTIFICATION) {
        return null;
    }
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
    for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
        FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
        if (faCatchType == FaCatchTypeEnum.ONBOARD) {
            handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
            if (faReportDocumentType == FaReportDocumentType.DECLARATION) {
                handleCumulatedCatchNoDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight);
            }
        }
    }
    return catchEvolutionProgressDTO;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FaReportDocumentType(eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)

Example 5 with FaCatchTypeEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class DISCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.

@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
    FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
    if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.DECLARATION) {
        return null;
    }
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
    for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
        FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
        if (faCatchType == FaCatchTypeEnum.DEMINIMIS || faCatchType == FaCatchTypeEnum.DISCARDED || faCatchType == FaCatchTypeEnum.UNLOADED) {
            handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
            handleCumulatedCatchWithDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight, Arrays.asList(FaCatchTypeEnum.DEMINIMIS, FaCatchTypeEnum.DISCARDED, FaCatchTypeEnum.UNLOADED));
        }
    }
    return catchEvolutionProgressDTO;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) FaCatchTypeEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum) CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FaReportDocumentType(eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)

Aggregations

FaCatchTypeEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum)10 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)7 FaReportDocumentType (eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)7 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)7 EnumMap (java.util.EnumMap)3 Map (java.util.Map)3 HashMap (java.util.HashMap)2 SummaryFACatchtype (eu.europa.ec.fisheries.uvms.activity.model.schemas.SummaryFACatchtype)1 ArrayList (java.util.ArrayList)1