Search in sources :

Example 1 with FaReportStatusEnum

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);
}
Also used : FaReportStatusEnum(eu.europa.ec.fisheries.ers.fa.utils.FaReportStatusEnum) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)

Aggregations

FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)1 FaReportStatusEnum (eu.europa.ec.fisheries.ers.fa.utils.FaReportStatusEnum)1 ArrayList (java.util.ArrayList)1 FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)1