Search in sources :

Example 1 with AapProcessEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class AapProductMapperTest method testMapToProcessingProduct.

@Test
public void testMapToProcessingProduct() {
    // Prepare
    FACatch faCatch = MapperUtil.getFaCatch();
    FaCatchEntity faCatchEntity = new FaCatchEntity();
    FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
    AAPProcess aapProcess = MapperUtil.getAapProcess();
    AapProcessEntity aapProcessEntity = AapProcessMapper.INSTANCE.mapToAapProcessEntity(aapProcess);
    aapProcessEntity.setFaCatch(faCatchEntity);
    AAPProduct aapProduct = MapperUtil.getAapProduct();
    AapProductEntity aapProductEntity = AapProductMapper.INSTANCE.mapToAapProductEntity(aapProduct);
    aapProductEntity.setAapProcess(aapProcessEntity);
    // Create Input data
    ProcessingProductsDto processingProductsDto = AapProductMapper.INSTANCE.mapToProcessingProduct(aapProductEntity);
    assertEquals(processingProductsDto.getType(), faCatchEntity.getTypeCode());
    assertEquals(processingProductsDto.getGear(), faCatchEntity.getGearTypeCode());
    assertEquals(processingProductsDto.getSpecies(), faCatchEntity.getSpeciesCode());
    assertNull(processingProductsDto.getPreservation());
    assertNull(processingProductsDto.getPresentation());
    assertNull(processingProductsDto.getFreshness());
    assertEquals(processingProductsDto.getConversionFactor(), aapProcessEntity.getConversionFactor().doubleValue());
    assertEquals(processingProductsDto.getWeight(), aapProductEntity.getCalculatedWeightMeasure());
    assertEquals(processingProductsDto.getQuantity(), aapProductEntity.getUnitQuantity());
    assertEquals(processingProductsDto.getPackageWeight(), aapProductEntity.getPackagingUnitAvarageWeight());
    assertEquals(processingProductsDto.getPackageQuantity().doubleValue(), aapProductEntity.getPackagingUnitCount().doubleValue());
    assertEquals(processingProductsDto.getPackagingType(), aapProductEntity.getPackagingTypeCode());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AAPProduct(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct) AAPProcess(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess) ProcessingProductsDto(eu.europa.ec.fisheries.ers.service.dto.view.ProcessingProductsDto) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) FACatch(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) Test(org.junit.Test)

Example 2 with AapProcessEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchMapperTest method testFaCatchMapper.

@Test
public void testFaCatchMapper() {
    FACatch faCatch = MapperUtil.getFaCatch();
    FaCatchEntity faCatchEntity = FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
    assertFaCatchFields(faCatch, faCatchEntity);
    assertNull(faCatchEntity.getFishingActivity());
    assertNotNull(faCatchEntity.getAapProcesses());
    AapProcessEntity aapProcessEntity = faCatchEntity.getAapProcesses().iterator().next();
    assertNotNull(aapProcessEntity);
    assertFaCatchFields(faCatch, aapProcessEntity.getFaCatch());
    assertNotNull(faCatchEntity.getAapStocks());
    AapStockEntity aapStockEntity = faCatchEntity.getAapStocks().iterator().next();
    assertNotNull(aapStockEntity);
    assertFaCatchFields(faCatch, aapStockEntity.getFaCatch());
    assertNotNull(faCatchEntity.getSizeDistribution());
    assertFaCatchFields(faCatch, faCatchEntity.getSizeDistribution().getFaCatch());
    assertNotNull(faCatchEntity.getFishingGears());
    FishingGearEntity fishingGearEntity = faCatchEntity.getFishingGears().iterator().next();
    assertNotNull(fishingGearEntity);
    assertFaCatchFields(faCatch, fishingGearEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFishingTrips());
    FishingTripEntity fishingTripEntity = faCatchEntity.getFishingTrips().iterator().next();
    assertNotNull(fishingTripEntity);
    assertFaCatchFields(faCatch, fishingTripEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFluxCharacteristics());
    FluxCharacteristicEntity fluxCharacteristicEntity = faCatchEntity.getFluxCharacteristics().iterator().next();
    assertNotNull(fluxCharacteristicEntity);
    assertFaCatchFields(faCatch, fluxCharacteristicEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFluxLocations());
    FluxLocationEntity fluxLocationEntity = faCatchEntity.getFluxLocations().iterator().next();
    assertNotNull(fluxLocationEntity);
    assertFaCatchFields(faCatch, fluxLocationEntity.getFaCatch());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AapStockEntity(eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity) FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) FACatch(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch) 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) Test(org.junit.Test)

Example 3 with AapProcessEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapperTest method testSpeciesCodeWithDuplicatedShouldFilterDuplicates.

@Test
public void testSpeciesCodeWithDuplicatedShouldFilterDuplicates() {
    FaCatchEntity faCatchEntity = new FaCatchEntity();
    faCatchEntity.setSpeciesCode("2222");
    AapProductEntity aapProductEntity = new AapProductEntity();
    aapProductEntity.setSpeciesCode("2222");
    AapProcessEntity aapProcessEntity = new AapProcessEntity();
    aapProcessEntity.setAapProducts(newSet(aapProductEntity));
    faCatchEntity.setAapProcesses(newSet(aapProcessEntity));
    FishingActivityEntity fa = FishingActivityEntity.builder().build();
    fa.setFaCatchs(newSet(faCatchEntity));
    List<String> speciesCode = FishingActivityMapper.INSTANCE.getSpeciesCode(fa);
    assertEquals(1, speciesCode.size());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) AapProductEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 4 with AapProcessEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchesProcessorMapper method extractLiveWeight.

private static Double extractLiveWeight(Set<AapProcessEntity> aapProcesses) {
    Double totalWeight = null;
    Double convFc = 1d;
    Double weightSum = 0.0;
    if (CollectionUtils.isNotEmpty(aapProcesses)) {
        for (AapProcessEntity aapProc : aapProcesses) {
            Double actConvFac = aapProc.getConversionFactor();
            convFc = (convFc == 1 && actConvFac != null) ? actConvFac : convFc;
            addToTotalWeightFromSetOfAapProduct(aapProc.getAapProducts(), weightSum);
        }
    }
    if (weightSum > 0.0) {
        totalWeight = convFc * weightSum;
    }
    return totalWeight;
}
Also used : AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)

Example 5 with AapProcessEntity

use of eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchMapper method getAapProcessEntities.

protected Set<AapProcessEntity> getAapProcessEntities(List<AAPProcess> aapProcesses, FaCatchEntity faCatchEntity) {
    if (aapProcesses == null || aapProcesses.isEmpty()) {
        return Collections.emptySet();
    }
    Set<AapProcessEntity> aapProcessEntities = new HashSet<>();
    for (AAPProcess aapProcess : aapProcesses) {
        AapProcessEntity aapProcessEntity = AapProcessMapper.INSTANCE.mapToAapProcessEntity(aapProcess);
        aapProcessEntity.setFaCatch(faCatchEntity);
        aapProcessEntities.add(aapProcessEntity);
    }
    return aapProcessEntities;
}
Also used : AAPProcess(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) HashSet(java.util.HashSet)

Aggregations

AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)6 Test (org.junit.Test)4 AapProductEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProductEntity)3 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)3 AAPProcess (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProcess)3 FACatch (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch)2 AapProcessCodeEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessCodeEntity)1 AapStockEntity (eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity)1 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)1 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)1 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)1 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)1 ProcessingProductsDto (eu.europa.ec.fisheries.ers.service.dto.view.ProcessingProductsDto)1 HashSet (java.util.HashSet)1 AAPProduct (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.AAPProduct)1