Search in sources :

Example 6 with FishingGearEntity

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

the class GearCharacteristicsMapper method mapFishingGearEntitiesToGearDtos.

public List<GearDto> mapFishingGearEntitiesToGearDtos(Set<FishingGearEntity> fishingGearEntities) {
    if (CollectionUtils.isEmpty(fishingGearEntities)) {
        return Collections.emptyList();
    }
    List<GearDto> gearDtoList = new ArrayList<>();
    for (FishingGearEntity gearEntity : fishingGearEntities) {
        GearDto gearDto = new GearDto();
        gearDto.setType(gearEntity.getTypeCode());
        fillRoleAndCharacteristics(gearDto, gearEntity);
        gearDtoList.add(gearDto);
    }
    return gearDtoList;
}
Also used : ArrayList(java.util.ArrayList) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) GearDto(eu.europa.ec.fisheries.ers.service.dto.view.GearDto)

Example 7 with FishingGearEntity

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

the class GearProblemMapper method getFishingGearsEntities.

protected Set<FishingGearEntity> getFishingGearsEntities(List<FishingGear> fishingGears, GearProblemEntity gearProblemEntity) {
    if (fishingGears == null || fishingGears.isEmpty()) {
        return Collections.emptySet();
    }
    Set<FishingGearEntity> fishingGearEntities = new HashSet<>();
    for (FishingGear fishingGear : fishingGears) {
        FishingGearEntity fishingGearEntity = FishingGearMapper.INSTANCE.mapToFishingGearEntity(fishingGear);
        fishingGearEntity.setGearProblem(gearProblemEntity);
        fishingGearEntities.add(fishingGearEntity);
    }
    return fishingGearEntities;
}
Also used : FishingGear(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingGear) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) HashSet(java.util.HashSet)

Example 8 with FishingGearEntity

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

the class FishingActivityMapper method getFishingGears.

protected Set<String> getFishingGears(FishingActivityEntity entity) {
    if (entity == null || entity.getFishingGears() == null) {
        return Collections.emptySet();
    }
    Set<String> gears = new HashSet<>();
    Set<FishingGearEntity> gearList = entity.getFishingGears();
    for (FishingGearEntity gear : gearList) {
        gears.add(gear.getTypeCode());
    }
    gears.remove(null);
    return gears;
}
Also used : FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) HashSet(java.util.HashSet)

Example 9 with FishingGearEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity 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)

Example 10 with FishingGearEntity

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

the class FishingGearMapperTest method testFishingGearMapperWithFaCatch.

@Test
public void testFishingGearMapperWithFaCatch() {
    FishingGear fishingGear = MapperUtil.getFishingGear();
    FishingGearEntity fishingGearEntity = FishingGearMapper.INSTANCE.mapToFishingGearEntity(fishingGear);
    assertEquals(fishingGear.getTypeCode().getValue(), fishingGearEntity.getTypeCode());
    assertEquals(fishingGear.getTypeCode().getListID(), fishingGearEntity.getTypeCodeListId());
    assertEquals(fishingGear.getRoleCodes().get(0).getValue(), fishingGearEntity.getFishingGearRole().iterator().next().getRoleCode());
    assertEquals(fishingGear.getRoleCodes().get(0).getListID(), fishingGearEntity.getFishingGearRole().iterator().next().getRoleCodeListId());
    assertNull(fishingGearEntity.getFaCatch());
    assertNotNull(fishingGearEntity.getGearCharacteristics());
    fishingGearEntity = fishingGearEntity.getGearCharacteristics().iterator().next().getFishingGear();
    assertEquals(fishingGear.getTypeCode().getValue(), fishingGearEntity.getTypeCode());
    assertEquals(fishingGear.getTypeCode().getListID(), fishingGearEntity.getTypeCodeListId());
    assertEquals(fishingGear.getRoleCodes().get(0).getValue(), fishingGearEntity.getFishingGearRole().iterator().next().getRoleCode());
    assertEquals(fishingGear.getRoleCodes().get(0).getListID(), fishingGearEntity.getFishingGearRole().iterator().next().getRoleCodeListId());
}
Also used : FishingGear(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingGear) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) Test(org.junit.Test)

Aggregations

FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)12 Test (org.junit.Test)7 FishingGear (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingGear)6 HashSet (java.util.HashSet)4 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)2 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)2 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)2 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)2 GearDto (eu.europa.ec.fisheries.ers.service.dto.view.GearDto)2 AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)1 AapStockEntity (eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity)1 DelimitedPeriodEntity (eu.europa.ec.fisheries.ers.fa.entities.DelimitedPeriodEntity)1 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1 GearProblemEntity (eu.europa.ec.fisheries.ers.fa.entities.GearProblemEntity)1 ArrayList (java.util.ArrayList)1 Parameters (junitparams.Parameters)1 FACatch (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch)1 FishingActivity (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)1 GearProblem (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.GearProblem)1