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