Search in sources :

Example 21 with FaCatchEntity

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;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) ArrayList(java.util.ArrayList)

Example 22 with FaCatchEntity

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;
}
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 23 with FaCatchEntity

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;
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)

Example 24 with 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);
}
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 25 with FaCatchEntity

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());
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) DelimitedPeriodEntity(eu.europa.ec.fisheries.ers.fa.entities.DelimitedPeriodEntity) FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) FishingActivityIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) FluxCharacteristicEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Aggregations

FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)28 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)11 Test (org.junit.Test)11 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)10 FaReportDocumentType (eu.europa.ec.fisheries.ers.fa.utils.FaReportDocumentType)7 FaCatchTypeEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum)7 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 SneakyThrows (lombok.SneakyThrows)4 AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)3 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)3 FishingActivityViewDTO (eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)3 BaseActivityViewMapper (eu.europa.ec.fisheries.ers.service.mapper.view.base.BaseActivityViewMapper)3 FACatch (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch)3 AapProductEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity)2 FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)2 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)2 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)2 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)2