use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class TripCatchEvolutionTest method testHandleCumulatedCatchWithDeletion.
@Test
public void testHandleCumulatedCatchWithDeletion() {
FaReportDocumentEntity faReportDocumentEntity = ActivityDataUtil.getFaReportDocumentEntity(FaReportDocumentType.DECLARATION.name(), "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), null, null, "new");
FishingActivityEntity fishingActivityEntity = ActivityDataUtil.getFishingActivityEntity(FishingActivityTypeEnum.DISCARD.name(), "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity, null);
FaCatchEntity faCatchEntity = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity, "DEMINIMIS", "FA_CATCH_TYPE", "COD", "FAO_SPECIES", 11112D, 11112.0D, "KGM", "BFT", "WEIGHT_MEANS", null);
faCatchEntity.setCalculatedWeightMeasure(11112D);
CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivityEntity, FaReportDocumentType.DECLARATION, new HashMap<String, Double>());
SpeciesQuantityDTO speciesQuantityDTO = new SpeciesQuantityDTO();
speciesQuantityDTO.setSpeciesCode("COD");
speciesQuantityDTO.setWeight(1000D);
catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").addSpecieAndQuantity("COD", 11112D, StringUtils.EMPTY);
catchEvolutionProgressDTO.getCatchEvolution().get("onboard").addSpecieAndQuantity("COD", 11112D, StringUtils.EMPTY);
catchEvolutionProgressDTO.getCatchEvolution().get("onboard").addSpecieAndQuantity("HKE", 11112D, StringUtils.EMPTY);
handleCumulatedCatchWithDeletion(faCatchEntity, catchEvolutionProgressDTO, new HashMap<String, Double>(), Arrays.asList(FaCatchTypeEnum.DEMINIMIS));
assertTrue(!catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().isEmpty());
assertEquals(catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().get(0).getSpeciesCode(), "COD");
assertTrue(catchEvolutionProgressDTO.getCatchEvolution().get("cumulated").getSpeciesList().get(0).getWeight() == 0);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getFishingTripEntity.
public static FishingTripEntity getFishingTripEntity() {
FishingTripEntity entity = new FishingTripEntity();
FluxReportDocumentEntity fluxReportDocumentEntity1 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT1", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID1", "flux1");
FluxReportDocumentEntity fluxReportDocumentEntity2 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT2", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID2", "flux2");
FluxReportDocumentEntity fluxReportDocumentEntity3 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT3", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID3", "flux3");
FluxReportDocumentEntity fluxReportDocumentEntity4 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT4", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID4", "flux4");
VesselTransportMeansEntity vesselTransportMeansEntity1 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup1", null);
VesselTransportMeansEntity vesselTransportMeansEntity2 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup2", null);
VesselTransportMeansEntity vesselTransportMeansEntity3 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup3", null);
vesselTransportMeansEntity1.setVesselIdentifiers(ActivityDataUtil.getVesselIdentifiers(vesselTransportMeansEntity1, "IDENT_1", "CFR"));
FaReportDocumentEntity faReportDocumentEntity1 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity1, vesselTransportMeansEntity1, "new");
FaReportDocumentEntity faReportDocumentEntity2 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity2, vesselTransportMeansEntity2, "new");
FaReportDocumentEntity faReportDocumentEntity3 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity3, vesselTransportMeansEntity3, "new");
FishingActivityEntity fishingActivityEntity1 = ActivityDataUtil.getFishingActivityEntity("DEPARTURE", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity1, null);
FishingActivityEntity fishingActivityEntity2 = ActivityDataUtil.getFishingActivityEntity("ARRIVAL", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity2, null);
FishingActivityEntity fishingActivityEntity3 = ActivityDataUtil.getFishingActivityEntity("LANDING", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity3, null);
SizeDistributionEntity sizeDistributionEntity = ActivityDataUtil.getSizeDistributionEntity("LSC", "FISH_SIZE_CLASS", "BFT", "FA_BFT_SIZE_CATEGORY");
FaCatchEntity faCatchEntity = ActivityDataUtil.getFaCatchEntity(fishingActivityEntity1, "DEPARTURE", "FA_CATCH_TYPE", "beagle2", "FAO_SPECIES", 11112D, 11112.0D, "FLUX_UNIT", "BFT", "WEIGHT_MEANS", sizeDistributionEntity);
entity = ActivityDataUtil.getFishingTripEntity("JFO", "EU_TRIP_ID", faCatchEntity, fishingActivityEntity1);
Set<FishingTripIdentifierEntity> fishingTripIdentifiers = new HashSet<>();
fishingTripIdentifiers.add(ActivityDataUtil.getFishingTripIdentifierEntity(entity, "NOR-TRP-20160517234053706", "EU_TRIP_ID"));
fishingTripIdentifiers.add(ActivityDataUtil.getFishingTripIdentifierEntity(entity, "NOR-TRP-20160517234053706", "EU_TRIP_ID"));
entity.setFishingTripIdentifiers(fishingTripIdentifiers);
return entity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getFaReportDocumentEntity.
public static FaReportDocumentEntity getFaReportDocumentEntity() {
FaReportDocumentEntity faReportDocumentEntity = new FaReportDocumentEntity();
faReportDocumentEntity.setStatus(FaReportStatusEnum.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<FaReportIdentifierEntity>(Arrays.asList(faReportIdentifierEntity)));
FluxReportDocumentEntity fluxReportDocumentEntity = getFluxReportDocumentEntity();
fluxReportDocumentEntity.setFaReportDocument(faReportDocumentEntity);
faReportDocumentEntity.setFluxReportDocument(fluxReportDocumentEntity);
return faReportDocumentEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method updateFaReportCorrections.
/**
* If there is a reference Id exist for any of the FaReport Document, than it means this is an update to an existing report.
*/
private void updateFaReportCorrections(List<FAReportDocument> faReportDocuments) throws ServiceException {
List<FaReportDocumentEntity> faReportDocumentEntities = new ArrayList<>();
for (FAReportDocument faReportDocument : faReportDocuments) {
if (faReportDocument.getRelatedFLUXReportDocument().getReferencedID() != null && faReportDocument.getRelatedFLUXReportDocument().getPurposeCode() != null) {
FaReportDocumentEntity faReportDocumentEntity = faReportDocumentDao.findFaReportByIdAndScheme(faReportDocument.getRelatedFLUXReportDocument().getReferencedID().getValue(), // Find the existing report by using reference Id and scheme Id
faReportDocument.getRelatedFLUXReportDocument().getReferencedID().getSchemeID());
if (faReportDocumentEntity != null) {
// If found then update the entity with respect to purpose code in the Report
FaReportStatusEnum faReportStatusEnum = FaReportStatusEnum.getFaReportStatusEnum(Integer.parseInt(faReportDocument.getRelatedFLUXReportDocument().getPurposeCode().getValue()));
faReportDocumentEntity.setStatus(faReportStatusEnum.getStatus());
faReportDocumentEntities.add(faReportDocumentEntity);
}
}
}
// Update all the Entities together
faReportDocumentDao.updateAllFaData(faReportDocumentEntities);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method saveFishingActivityReportDocuments.
/**
* {@inheritDoc}
*/
@Override
@Transactional(Transactional.TxType.REQUIRED)
public void saveFishingActivityReportDocuments(FLUXFAReportMessage faReportMessage, FaReportSourceEnum faReportSourceEnum) throws ServiceException {
log.info("[INFO] Going to save [ " + faReportMessage.getFAReportDocuments().size() + " ] FaReportDocuments..");
FluxFaReportMessageEntity messageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(faReportMessage, faReportSourceEnum, new FluxFaReportMessageEntity());
final Set<FaReportDocumentEntity> faReportDocuments = messageEntity.getFaReportDocuments();
for (FaReportDocumentEntity faReportDocument : faReportDocuments) {
try {
updateGeometry(faReportDocument);
enrichFishingActivityWithGuiID(faReportDocument);
} catch (Exception e) {
log.error("Could not update Geometry OR enrichActivities for faReportDocument:" + faReportDocument.getId());
}
}
log.debug("fishing activity records to be saved : " + faReportDocuments.size());
fluxReportMessageDao.saveFluxFaReportMessage(messageEntity);
log.debug("Save partial FluxFaReportMessage before further processing");
updateFaReportCorrections(faReportMessage.getFAReportDocuments());
log.debug("Update FaReport Corrections is complete.");
updateFishingTripStartAndEndDate(faReportDocuments);
log.info("FluxFaReportMessage Saved successfully.");
}
Aggregations