Search in sources :

Example 1 with FaReportDocumentEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity 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 2 with FaReportDocumentEntity

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

the class FAQueryServiceBean method getReportsByCriteria.

@Override
public Object getReportsByCriteria(List<SubscriptionDataCriteria> subscriptionDataCriteria) {
    if (CollectionUtils.isNotEmpty(subscriptionDataCriteria)) {
        String consolidated = "N";
        String tripID = null;
        String vesselId = null;
        String schemeId = null;
        String endDate = null;
        String startDate = null;
        for (SubscriptionDataCriteria dataCriteria : subscriptionDataCriteria) {
            SubCriteriaType subCriteria = dataCriteria.getSubCriteria();
            String valueType = dataCriteria.getValueType().value();
            String value = dataCriteria.getValue();
            if (subCriteria == SubCriteriaType.END_DATE) {
                endDate = value;
            } else if (subCriteria == SubCriteriaType.START_DATE) {
                startDate = value;
            } else if (subCriteria == SubCriteriaType.TRIPID) {
                tripID = value;
            } else if (subCriteria == SubCriteriaType.CONSOLIDATED) {
                consolidated = value;
            } else if (subCriteria == SubCriteriaType.VESSELID) {
                schemeId = valueType;
                vesselId = value;
            }
        }
        List<FaReportDocumentEntity> faReportDocumentsForTrip = FAReportDAO.loadReports(tripID, consolidated, vesselId, schemeId, startDate, endDate);
        ActivityEntityToModelMapper faReportEntityToModelMapper = new ActivityEntityToModelMapper();
        return faReportEntityToModelMapper.mapToFLUXFAReportMessage(faReportDocumentsForTrip);
    }
    return null;
}
Also used : SubCriteriaType(eu.europa.ec.fisheries.wsdl.subscription.module.SubCriteriaType) ActivityEntityToModelMapper(eu.europa.ec.fisheries.ers.service.mapper.ActivityEntityToModelMapper) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) SubscriptionDataCriteria(eu.europa.ec.fisheries.wsdl.subscription.module.SubscriptionDataCriteria)

Example 3 with FaReportDocumentEntity

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

the class FishingTripServiceBean method getTripMapDetailsForTripId.

/**
 * Retrieve GEO data for fishing trip Map for tripID
 *
 * @param tripId
 * @return
 */
@Override
public ObjectNode getTripMapDetailsForTripId(String tripId) {
    log.info("Get GEO data for Fishing Trip for tripId:" + tripId);
    List<FaReportDocumentEntity> faReportDocumentEntityList = faReportDocumentDao.loadReports(tripId, "Y");
    List<Geometry> geoList = new ArrayList<>();
    for (FaReportDocumentEntity entity : faReportDocumentEntityList) {
        if (entity.getGeom() != null)
            geoList.add(entity.getGeom());
    }
    return FishingTripToGeoJsonMapper.toJson(geoList);
}
Also used : FishingTripIdWithGeometry(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList)

Example 4 with FaReportDocumentEntity

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

the class ActivityServiceBean method getReferencedFaReportDocuments.

private List<FaReportDocumentEntity> getReferencedFaReportDocuments(String refReportId, String refSchemeId) throws ServiceException {
    if (refReportId == null || refSchemeId == null) {
        return Collections.emptyList();
    }
    log.info("Find reference fishing activity report for : " + refReportId + " scheme Id : " + refReportId);
    List<FaReportDocumentEntity> allFaReportDocuments = new ArrayList<>();
    FaReportDocumentEntity faReportDocumentEntity = faReportDocumentDao.findFaReportByIdAndScheme(refReportId, refSchemeId);
    if (faReportDocumentEntity != null) {
        allFaReportDocuments.add(faReportDocumentEntity);
        allFaReportDocuments.addAll(getReferencedFaReportDocuments(faReportDocumentEntity.getFluxReportDocument().getReferenceId(), faReportDocumentEntity.getFluxReportDocument().getReferenceSchemeId()));
    }
    return allFaReportDocuments;
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList)

Example 5 with FaReportDocumentEntity

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

the class FluxMessageServiceBeanTest method testSaveFishingActivityReportDocuments.

@Test
@SneakyThrows
public void testSaveFishingActivityReportDocuments() throws ServiceException, ParseException, DatatypeConfigurationException {
    // Mock the APIs
    Mockito.doNothing().when(faReportDocumentDao).bulkUploadFaData(Mockito.any(List.class));
    Mockito.doNothing().when(faReportDocumentDao).updateAllFaData(Mockito.any(List.class));
    Mockito.doNothing().when(fluxFaReportMessageDao).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.doReturn(getMockedAssets()).when(assetModule).getAssetGuids(Mockito.anyCollection());
    Mockito.doReturn(getMockedMovements()).when(movementModule).getMovement(Mockito.anyList(), Mockito.any(Date.class), Mockito.any(Date.class));
    Mockito.doReturn(getMockedFishingActivityReportEntity()).when(faReportDocumentDao).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    // Trigger
    fluxMessageService.setDialect(new PostGres());
    fluxMessageService.saveFishingActivityReportDocuments(fluxFaReportMessage, FaReportSourceEnum.FLUX);
    // Verify
    Mockito.verify(fluxFaReportMessageDao, Mockito.times(1)).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).updateAllFaData(captor.capture());
    // Test
    List<FaReportDocumentEntity> faReportDocumentEntities = captor.getValue();
    assertEquals(FaReportStatusEnum.getFaReportStatusEnum(Integer.parseInt(faReportDocuments.get(1).getRelatedFLUXReportDocument().getPurposeCode().getValue())).getStatus(), faReportDocumentEntities.get(0).getStatus());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) List(java.util.List) PostGres(eu.europa.ec.fisheries.ers.service.util.PostGres) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Date(java.util.Date) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)24 ArrayList (java.util.ArrayList)10 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)8 Test (org.junit.Test)7 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)5 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)5 FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)4 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)4 SneakyThrows (lombok.SneakyThrows)4 FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)4 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 ParseException (com.vividsolutions.jts.io.ParseException)2 FaReportIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity)2 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)2 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)2 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)1