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);
}
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()));
}
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);
}
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;
}
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;
}
Aggregations