use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchesProcessorMapper method extractOneGroup.
/**
* Extracts a group that has the needed properties in common with the catchesIteratorExt.next()
*
* @param faCatchesSet Set<FaCatchEntity>
* @return
*/
private static List<FaCatchEntity> extractOneGroup(Set<FaCatchEntity> faCatchesSet) {
List<FaCatchEntity> group = new ArrayList<>();
Iterator<FaCatchEntity> catchesIteratorInt = faCatchesSet.iterator();
FaCatchEntity extCatch = catchesIteratorInt.next();
group.add(extCatch);
while (catchesIteratorInt.hasNext()) {
FaCatchEntity intCatch = catchesIteratorInt.next();
if (FaCatchForViewComparator.catchesAreEqual(extCatch, intCatch)) {
group.add(intCatch);
}
}
faCatchesSet.removeAll(group);
return group;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity 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.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityDataUtil method getFaCatchEntity.
public static FaCatchEntity getFaCatchEntity(FishingActivityEntity fishingActivityEntity, String typeCode, String typeCodeListId, String speciesCode, String speciesCodeListid, Double unitQuantity, Double weightMeasure, String weightMeasureUnitCode, String weighingMeansCode, String weighingMeansCodeListId, SizeDistributionEntity sizeDistributionEntity) {
FaCatchEntity faCatchEntity = new FaCatchEntity();
faCatchEntity.setFishingActivity(fishingActivityEntity);
faCatchEntity.setTypeCode(typeCode);
faCatchEntity.setTypeCodeListId(typeCodeListId);
faCatchEntity.setSpeciesCode(speciesCode);
faCatchEntity.setSpeciesCodeListid(speciesCodeListid);
faCatchEntity.setUnitQuantity(unitQuantity);
faCatchEntity.setWeightMeasure(weightMeasure);
faCatchEntity.setWeightMeasureUnitCode(weightMeasureUnitCode);
faCatchEntity.setWeighingMeansCode(weighingMeansCode);
faCatchEntity.setSizeDistribution(sizeDistributionEntity);
faCatchEntity.setWeighingMeansCodeListId(weighingMeansCodeListId);
return faCatchEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity 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);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapperTest method testFishingActivityMapper.
@Test
public void testFishingActivityMapper() {
FishingActivity fishingActivity = MapperUtil.getFishingActivity();
FishingActivityEntity fishingActivityEntity = new FishingActivityEntity();
FishingActivityMapper.INSTANCE.mapToFishingActivityEntity(fishingActivity, null, fishingActivityEntity);
assertFishingActivityFields(fishingActivity, fishingActivityEntity);
assertNull(fishingActivityEntity.getFaReportDocument());
assertNotNull(fishingActivityEntity.getFishingGears());
FishingGearEntity fishingGearEntity = fishingActivityEntity.getFishingGears().iterator().next();
assertNotNull(fishingGearEntity);
assertFishingActivityFields(fishingActivity, fishingGearEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getFishingTrips());
FishingTripEntity fishingTripEntity = fishingActivityEntity.getFishingTrips().iterator().next();
assertNotNull(fishingTripEntity);
assertFishingActivityFields(fishingActivity, fishingTripEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getFaCatchs());
FaCatchEntity faCatchEntity = fishingActivityEntity.getFaCatchs().iterator().next();
assertNotNull(faCatchEntity);
assertFishingActivityFields(fishingActivity, faCatchEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getSourceVesselCharId());
assertFishingActivityFields(fishingActivity, fishingActivityEntity.getSourceVesselCharId().getFishingActivitiesForSourceVesselCharId());
assertNotNull(fishingActivityEntity.getDestVesselCharId());
assertFishingActivityFields(fishingActivity, fishingActivityEntity.getDestVesselCharId().getFishingActivitiesForDestVesselCharId());
assertNotNull(fishingActivityEntity.getDelimitedPeriods());
DelimitedPeriodEntity delimitedPeriodEntity = fishingActivityEntity.getDelimitedPeriods().iterator().next();
assertNotNull(delimitedPeriodEntity);
assertFishingActivityFields(fishingActivity, delimitedPeriodEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getFluxCharacteristics());
FluxCharacteristicEntity fluxCharacteristicEntity = fishingActivityEntity.getFluxCharacteristics().iterator().next();
assertNotNull(fluxCharacteristicEntity);
assertFishingActivityFields(fishingActivity, fluxCharacteristicEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getFluxLocations());
FluxLocationEntity fluxLocationEntity = fishingActivityEntity.getFluxLocations().iterator().next();
assertNotNull(fluxLocationEntity);
assertFishingActivityFields(fishingActivity, fluxLocationEntity.getFishingActivity());
assertNotNull(fishingActivityEntity.getAllRelatedFishingActivities());
FishingActivityEntity relatedFishingActivityEntity = fishingActivityEntity.getAllRelatedFishingActivities().iterator().next();
assertNotNull(relatedFishingActivityEntity);
assertFishingActivityFields(fishingActivity.getRelatedFishingActivities().get(0), relatedFishingActivityEntity);
assertNotNull(fishingActivityEntity.getFishingActivityIdentifiers());
FishingActivityIdentifierEntity fishingActivityIdentifierEntity = fishingActivityEntity.getFishingActivityIdentifiers().iterator().next();
assertNotNull(fishingActivityIdentifierEntity);
assertEquals(fishingActivity.getIDS().get(0).getValue(), fishingActivityIdentifierEntity.getFaIdentifierId());
assertEquals(fishingActivity.getIDS().get(0).getSchemeID(), fishingActivityIdentifierEntity.getFaIdentifierSchemeId());
assertFishingActivityFields(fishingActivity, fishingActivityIdentifierEntity.getFishingActivity());
}
Aggregations