Search in sources :

Example 11 with CatchEvolutionProgressDTO

use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class CatchEvolutionProgressProcessor method process.

public List<CatchEvolutionProgressDTO> process(List<FishingActivityEntity> fishingActivities) {
    Map<String, Double> speciesCumulatedWeight = new HashMap<>();
    List<CatchEvolutionProgressDTO> catchEvolutionProgressDTOs = new ArrayList<>();
    Collections.sort(fishingActivities, new FishingActivityCalculatedDateComparator());
    int orderId = 1;
    for (FishingActivityEntity fishingActivity : fishingActivities) {
        FishingActivityTypeEnum fishingActivityType = EnumUtils.getEnum(FishingActivityTypeEnum.class, fishingActivity.getTypeCode());
        if (fishingActivityType != null && catchEvolutionProgressRegistry != null && catchEvolutionProgressRegistry.containsHandler(fishingActivityType)) {
            CatchEvolutionProgressHandler catchEvolutionProgressHandler = catchEvolutionProgressRegistry.findHandler(fishingActivityType);
            CatchEvolutionProgressDTO catchEvolutionProgressDTO = catchEvolutionProgressHandler.prepareCatchEvolutionProgressDTO(fishingActivity, speciesCumulatedWeight);
            if (catchEvolutionProgressDTO != null) {
                catchEvolutionProgressDTO.setOrderId(orderId++);
                catchEvolutionProgressDTOs.add(catchEvolutionProgressDTO);
            }
        }
    }
    return catchEvolutionProgressDTOs;
}
Also used : CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) FishingActivityTypeEnum(eu.europa.ec.fisheries.ers.fa.utils.FishingActivityTypeEnum)

Example 12 with CatchEvolutionProgressDTO

use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FOPCatchEvolutionProgressHandler 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.ONBOARD || faCatchType == FaCatchTypeEnum.KEPT_IN_NET || faCatchType == FaCatchTypeEnum.BY_CATCH) {
            handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
            handleCumulatedCatchNoDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight);
        } else if (faCatchType == FaCatchTypeEnum.TAKEN_ON_BOARD && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.TAKEN_ON_BOARD)) {
            handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
            handleCumulatedCatchWithDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight, Arrays.asList(FaCatchTypeEnum.DEMINIMIS, FaCatchTypeEnum.DISCARDED));
        }
    }
    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 13 with CatchEvolutionProgressDTO

use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class TripCatchEvolutionTest method testHandleCumulatedCatchNoDeletion.

@Test
public void testHandleCumulatedCatchNoDeletion() {
    FaReportDocumentEntity faReportDocumentEntity = ActivityDataUtil.getFaReportDocumentEntity(FaReportDocumentType.DECLARATION.name(), "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), null, null, "new");
    FishingActivityEntity fishingActivityEntity = ActivityDataUtil.getFishingActivityEntity(FishingActivityTypeEnum.FISHING_OPERATION.name(), "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity, null);
    FaCatchEntity faCatchEntity = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity, "LOADED", "FA_CATCH_TYPE", "COD", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", null);
    faCatchEntity.setCalculatedWeightMeasure(11112D);
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivityEntity, FaReportDocumentType.DECLARATION, new HashMap<String, Double>());
    handleCumulatedCatchNoDeletion(faCatchEntity, catchEvolutionProgressDTO, new HashMap<String, Double>());
    assertTrue(!catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().isEmpty());
    assertEquals(catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().get(0).getSpeciesCode(), "COD");
    assertTrue(catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().get(0).getWeight() == 11112D);
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Aggregations

CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)13 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)10 FaReportDocumentType (eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)7 FaCatchTypeEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum)7 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)5 Test (org.junit.Test)4 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)3 SpeciesQuantityDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO)2 FishingActivityTypeEnum (eu.europa.ec.fisheries.ers.fa.utils.FishingActivityTypeEnum)1 CatchSummaryListDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1