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);
}
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;
}
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);
}
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;
}
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());
}
Aggregations