Search in sources :

Example 1 with CatchEvolutionProgressDTO

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

the class TripCatchEvolutionTest method testHandleOnboardCatch.

@Test
public void testHandleOnboardCatch() {
    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>());
    handleOnboardCatch(faCatchEntity, catchEvolutionProgressDTO);
    assertTrue(!catchEvolutionProgressDTO.getCatchEvolution().get("onboard").getSpeciesList().isEmpty());
    assertEquals(catchEvolutionProgressDTO.getCatchEvolution().get("onboard").getSpeciesList().get(0).getSpeciesCode(), "COD");
    assertTrue(catchEvolutionProgressDTO.getCatchEvolution().get("onboard").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)

Example 2 with CatchEvolutionProgressDTO

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

the class TripCatchEvolutionTest method testInitCatchEvolutionProgressDTO.

@Test
public void testInitCatchEvolutionProgressDTO() {
    FishingActivityEntity fishingActivityEntity = ActivityDataUtil.getFishingActivityEntity("DEPARTURE", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", null, null);
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivityEntity, FaReportDocumentType.DECLARATION, new HashMap<String, Double>());
    assertTrue(catchEvolutionProgressDTO.getCatchEvolution().containsKey("onboard"));
    assertTrue(catchEvolutionProgressDTO.getCatchEvolution().containsKey("cumulated"));
    assertTrue(catchEvolutionProgressDTO.getReportType().equals(FaReportDocumentType.DECLARATION.name()));
}
Also used : CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 3 with CatchEvolutionProgressDTO

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

the class TripCatchEvolutionTest method testHandleCumulatedCatchWithDeletion.

@Test
public void testHandleCumulatedCatchWithDeletion() {
    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.DISCARD.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, "DEMINIMIS", "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>());
    SpeciesQuantityDTO speciesQuantityDTO = new SpeciesQuantityDTO();
    speciesQuantityDTO.setSpeciesCode("COD");
    speciesQuantityDTO.setWeight(1000D);
    catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").addSpecieAndQuantity("COD", 11112D, StringUtils.EMPTY);
    catchEvolutionProgressDTO.getCatchEvolution().get("onboard").addSpecieAndQuantity("COD", 11112D, StringUtils.EMPTY);
    catchEvolutionProgressDTO.getCatchEvolution().get("onboard").addSpecieAndQuantity("HKE", 11112D, StringUtils.EMPTY);
    handleCumulatedCatchWithDeletion(faCatchEntity, catchEvolutionProgressDTO, new HashMap<String, Double>(), Arrays.asList(FaCatchTypeEnum.DEMINIMIS));
    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() == 0);
}
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) SpeciesQuantityDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 4 with CatchEvolutionProgressDTO

use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO 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 5 with CatchEvolutionProgressDTO

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

the class CatchEvolutionProgressHandler method initCatchEvolutionProgressDTO.

protected CatchEvolutionProgressDTO initCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, FaReportDocumentType faReportDocumentType, Map<String, Double> speciesCumulatedWeight) {
    CatchSummaryListDTO onboard = new CatchSummaryListDTO();
    CatchSummaryListDTO cumulated = new CatchSummaryListDTO();
    Map<String, CatchSummaryListDTO> catchEvolution = new TreeMap<>();
    catchEvolution.put("onboard", onboard);
    catchEvolution.put("cumulated", cumulated);
    CatchEvolutionProgressDTO catchEvolutionProgressDTO = new CatchEvolutionProgressDTO();
    catchEvolutionProgressDTO.setActivityType(fishingActivity.getTypeCode());
    catchEvolutionProgressDTO.setCatchEvolution(catchEvolution);
    catchEvolutionProgressDTO.setReportType(faReportDocumentType.name());
    for (Map.Entry scw : speciesCumulatedWeight.entrySet()) {
        SpeciesQuantityDTO speciesQuantityDTO = new SpeciesQuantityDTO();
        speciesQuantityDTO.setSpeciesCode((String) scw.getKey());
        Double weight = (Double) scw.getValue();
        speciesQuantityDTO.setWeight(weight);
        cumulated.getSpeciesList().add(speciesQuantityDTO);
        cumulated.setTotal(cumulated.getTotal() + weight);
    }
    return catchEvolutionProgressDTO;
}
Also used : CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) SpeciesQuantityDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.SpeciesQuantityDTO) CatchSummaryListDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchSummaryListDTO) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map)

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