Search in sources :

Example 1 with FaReportIdentifierEntity

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

the class MapperUtil method getFaReportDocumentEntity.

public static FaReportDocumentEntity getFaReportDocumentEntity() {
    FaReportDocumentEntity faReportDocumentEntity = new FaReportDocumentEntity();
    faReportDocumentEntity.setStatus(FaReportStatusType.UPDATED.getStatus());
    faReportDocumentEntity.setTypeCode("FISHING_OPERATION");
    faReportDocumentEntity.setTypeCodeListId("FLUX_FA_REPORT_TYPE");
    faReportDocumentEntity.setAcceptedDatetime(new Date());
    faReportDocumentEntity.setFmcMarker("FMC Marker");
    faReportDocumentEntity.setFmcMarkerListId("FMC Marker list Id");
    Geometry geometry = null;
    try {
        geometry = wktReader.read("MULTIPOINT ((-10 40), (-40 30), (-20 20), (-30 10))");
    } catch (ParseException e) {
        e.printStackTrace();
    }
    faReportDocumentEntity.setGeom(geometry);
    FaReportIdentifierEntity faReportIdentifierEntity = new FaReportIdentifierEntity();
    faReportIdentifierEntity.setFaReportIdentifierId("Identifier Id 1");
    faReportIdentifierEntity.setFaReportIdentifierSchemeId("57th785-tjf845-tjfui5-tjfuir8");
    faReportIdentifierEntity.setFaReportDocument(faReportDocumentEntity);
    faReportDocumentEntity.setFaReportIdentifiers(new HashSet<>(Collections.singletonList(faReportIdentifierEntity)));
    FluxReportDocumentEntity fluxReportDocumentEntity = getFluxReportDocumentEntity();
    fluxReportDocumentEntity.setFaReportDocument(faReportDocumentEntity);
    faReportDocumentEntity.setFluxReportDocument(fluxReportDocumentEntity);
    return faReportDocumentEntity;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) ParseException(com.vividsolutions.jts.io.ParseException) FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) Date(java.util.Date)

Example 2 with FaReportIdentifierEntity

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

the class FaReportDocumentMapperTest method testFaReportDocumentMapperNullReturns.

@Test
public void testFaReportDocumentMapperNullReturns() {
    Set<FishingActivityEntity> fishingActivityEntities = FaReportDocumentMapper.INSTANCE.getFishingActivityEntities(null, new FaReportDocumentEntity());
    assertTrue(fishingActivityEntities.size() == 0);
    Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = FaReportDocumentMapper.INSTANCE.getVesselTransportMeansEntity(null, new FaReportDocumentEntity());
    assertNull(vesselTransportMeansEntityList);
    Set<FishingActivityEntity> fishingActivityEntities1 = FaReportDocumentMapper.INSTANCE.getFishingActivityEntities(null, new FaReportDocumentEntity());
    assertTrue(fishingActivityEntities1.size() == 0);
    Set<FaReportIdentifierEntity> faReportIdentifierEntities = FaReportDocumentMapper.INSTANCE.mapToFAReportIdentifierEntities(null, new FaReportDocumentEntity());
    assertTrue(faReportIdentifierEntities.size() == 0);
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Example 3 with FaReportIdentifierEntity

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

the class ActivityEntityToModelMapper method mapRelatedReportIDs.

private void mapRelatedReportIDs(FAReportDocument target, Set<FaReportIdentifierEntity> faReportIdentifiers) {
    if (CollectionUtils.isNotEmpty(faReportIdentifiers)) {
        List<IDType> idTypeList = new ArrayList<>();
        for (FaReportIdentifierEntity source : faReportIdentifiers) {
            IDType idType = new IDType();
            String faReportIdentifierId = source.getFaReportIdentifierId();
            String faReportIdentifierSchemeId = source.getFaReportIdentifierSchemeId();
            idType.setSchemeID(faReportIdentifierSchemeId);
            idType.setValue(faReportIdentifierId);
            idTypeList.add(idType);
        }
        target.setRelatedReportIDs(idTypeList);
    }
}
Also used : ArrayList(java.util.ArrayList) FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)

Example 4 with FaReportIdentifierEntity

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

the class FaReportDocumentMapper method mapToFAReportIdentifierEntities.

protected Set<FaReportIdentifierEntity> mapToFAReportIdentifierEntities(List<IDType> idTypes, FaReportDocumentEntity faReportDocumentEntity) {
    if (CollectionUtils.isEmpty(idTypes)) {
        return Collections.emptySet();
    }
    Set<FaReportIdentifierEntity> faReportIdentifierEntities = new HashSet<>();
    for (IDType idType : idTypes) {
        FaReportIdentifierEntity faReportIdentifierEntity = FaReportDocumentMapper.INSTANCE.mapToFAReportIdentifierEntity(idType);
        faReportIdentifierEntity.setFaReportDocument(faReportDocumentEntity);
        faReportIdentifierEntities.add(faReportIdentifierEntity);
    }
    return faReportIdentifierEntities;
}
Also used : FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) HashSet(java.util.HashSet)

Example 5 with FaReportIdentifierEntity

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

the class FaReportDocumentMapperTest method testFaReportDocumentMapper.

@Test
public void testFaReportDocumentMapper() {
    FAReportDocument faReportDocument = MapperUtil.getFaReportDocument();
    FaReportDocumentEntity faReportDocumentEntity = FaReportDocumentMapper.INSTANCE.mapToFAReportDocumentEntity(faReportDocument, FaReportSourceEnum.FLUX);
    assertFaReportDocumentFields(faReportDocument, faReportDocumentEntity);
    assertNotNull(faReportDocumentEntity.getFaReportIdentifiers());
    FaReportIdentifierEntity faReportIdentifierEntity = faReportDocumentEntity.getFaReportIdentifiers().iterator().next();
    assertNotNull(faReportDocumentEntity);
    assertEquals(faReportDocument.getRelatedReportIDs().get(0).getValue(), faReportIdentifierEntity.getFaReportIdentifierId());
    assertEquals(faReportDocument.getRelatedReportIDs().get(0).getSchemeID(), faReportIdentifierEntity.getFaReportIdentifierSchemeId());
    assertFaReportDocumentFields(faReportDocument, faReportIdentifierEntity.getFaReportDocument());
    assertNotNull(faReportDocumentEntity.getFishingActivities());
    FishingActivityEntity fishingActivityEntity = faReportDocumentEntity.getFishingActivities().iterator().next();
    assertNotNull(fishingActivityEntity);
    assertFaReportDocumentFields(faReportDocument, fishingActivityEntity.getFaReportDocument());
    assertNotNull(faReportDocumentEntity.getFluxReportDocument());
    assertFaReportDocumentFields(faReportDocument, faReportDocumentEntity.getFluxReportDocument().getFaReportDocument());
    assertNotNull(faReportDocumentEntity.getVesselTransportMeans());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FaReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) Test(org.junit.Test)

Aggregations

FaReportIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity)5 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)3 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 Test (org.junit.Test)2 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 ParseException (com.vividsolutions.jts.io.ParseException)1 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)1