use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.MessageCountDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method createMessageCounter.
/**
* Populates the MessageCounter adding to the right counter 1 unit depending on the type of report (typeCode, purposeCode, size()).
*
* @param faReportDocumentList
*/
public MessageCountDTO createMessageCounter(List<FaReportDocumentEntity> faReportDocumentList) {
MessageCountDTO messagesCounter = new MessageCountDTO();
if (CollectionUtils.isEmpty(faReportDocumentList)) {
return messagesCounter;
}
// Reports total
messagesCounter.setNoOfReports(faReportDocumentList.size());
for (FaReportDocumentEntity faReport : faReportDocumentList) {
String faDocumentType = faReport.getTypeCode();
String purposeCode = faReport.getFluxReportDocument().getPurpose();
// Declarations / Notifications
if (ActivityConstants.DECLARATION.equalsIgnoreCase(faDocumentType)) {
messagesCounter.setNoOfDeclarations(messagesCounter.getNoOfDeclarations() + 1);
} else if (ActivityConstants.NOTIFICATION.equalsIgnoreCase(faDocumentType)) {
messagesCounter.setNoOfNotifications(messagesCounter.getNoOfNotifications() + 1);
}
// Fishing operations
Set<FishingActivityEntity> faEntitiyList = faReport.getFishingActivities();
if (isNotEmpty(faEntitiyList)) {
for (FishingActivityEntity faEntity : faEntitiyList) {
if (FishingActivityTypeEnum.FISHING_OPERATION.toString().equalsIgnoreCase(faEntity.getTypeCode())) {
messagesCounter.setNoOfFishingOperations(messagesCounter.getNoOfFishingOperations() + 1);
}
}
}
// PurposeCode : Deletions / Cancellations / Corrections
if (ActivityConstants.DELETE.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfDeletions(messagesCounter.getNoOfDeletions() + 1);
} else if (ActivityConstants.CANCELLATION.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfCancellations(messagesCounter.getNoOfCancellations() + 1);
} else if (ActivityConstants.CORRECTION.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfCorrections(messagesCounter.getNoOfCorrections() + 1);
}
}
return messagesCounter;
}
Aggregations