Search in sources :

Example 1 with GearProblemEntity

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

the class FishingActivityMapper method getGearProblemEntities.

protected Set<GearProblemEntity> getGearProblemEntities(List<GearProblem> gearProblems, FishingActivityEntity fishingActivityEntity) {
    if (gearProblems == null || gearProblems.isEmpty()) {
        return Collections.emptySet();
    }
    Set<GearProblemEntity> gearProblemEntities = new HashSet<>();
    for (GearProblem gearProblem : gearProblems) {
        GearProblemEntity gearProblemEntity = GearProblemMapper.INSTANCE.mapToGearProblemEntity(gearProblem);
        gearProblemEntity.setFishingActivity(fishingActivityEntity);
        gearProblemEntities.add(gearProblemEntity);
    }
    return gearProblemEntities;
}
Also used : GearProblem(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.GearProblem) GearProblemEntity(eu.europa.ec.fisheries.ers.fa.entities.GearProblemEntity) HashSet(java.util.HashSet)

Example 2 with GearProblemEntity

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

the class GearProblemMapperTest method testGearProblemMapper.

@Test
public void testGearProblemMapper() {
    GearProblem gearProblem = MapperUtil.getGearProblem();
    GearProblemEntity gearProblemEntity = GearProblemMapper.INSTANCE.mapToGearProblemEntity(gearProblem);
    assertEquals(gearProblem.getTypeCode().getValue(), gearProblemEntity.getTypeCode());
    assertEquals(gearProblem.getTypeCode().getListID(), gearProblemEntity.getTypeCodeListId());
    assertEquals(gearProblem.getAffectedQuantity().getValue().intValue(), gearProblemEntity.getAffectedQuantity());
    assertEquals(gearProblem.getRecoveryMeasureCodes().get(0).getValue(), gearProblemEntity.getGearProblemRecovery().iterator().next().getRecoveryMeasureCode());
    assertEquals(gearProblem.getRecoveryMeasureCodes().get(0).getListID(), gearProblemEntity.getGearProblemRecovery().iterator().next().getRecoveryMeasureCodeListId());
    assertNull(gearProblemEntity.getFishingActivity());
    assertNotNull(gearProblemEntity.getFishingGears());
    FishingGearEntity fishingGearEntity = gearProblemEntity.getFishingGears().iterator().next();
    assertEquals(gearProblem.getTypeCode().getValue(), fishingGearEntity.getGearProblem().getTypeCode());
    assertEquals(gearProblem.getTypeCode().getListID(), fishingGearEntity.getGearProblem().getTypeCodeListId());
    assertEquals(gearProblem.getAffectedQuantity().getValue().intValue(), fishingGearEntity.getGearProblem().getAffectedQuantity());
    assertEquals(gearProblem.getRecoveryMeasureCodes().get(0).getValue(), fishingGearEntity.getGearProblem().getGearProblemRecovery().iterator().next().getRecoveryMeasureCode());
    assertEquals(gearProblem.getRecoveryMeasureCodes().get(0).getListID(), fishingGearEntity.getGearProblem().getGearProblemRecovery().iterator().next().getRecoveryMeasureCodeListId());
    assertEquals(gearProblemEntity.getTypeCode(), "Code Type 1");
    assertEquals(gearProblemEntity.getTypeCodeListId(), "fhty58-gh586t-5tjf8-t58rjewe");
    gearProblemEntity.getLocations().iterator().next().onPrePersist();
    assertNotNull(gearProblemEntity.getLocations().iterator().next().getGeom());
}
Also used : GearProblem(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.GearProblem) GearProblemEntity(eu.europa.ec.fisheries.ers.fa.entities.GearProblemEntity) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) Test(org.junit.Test)

Aggregations

GearProblemEntity (eu.europa.ec.fisheries.ers.fa.entities.GearProblemEntity)2 GearProblem (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.GearProblem)2 FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1