use of eu.europa.ec.fisheries.ers.fa.utils.FaReportStatusEnum 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);
}
Aggregations