use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryPresentationHelper method populateTotalFaCatchMap.
@Override
public void populateTotalFaCatchMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
Map<FaCatchTypeEnum, Object> catchTypeEnumMapMap = summaryTable.getSummaryFaCatchType();
if (MapUtils.isNotEmpty(catchTypeEnumMapMap)) {
Map<FaCatchTypeEnum, Object> totalCatchTypeMap = summaryTableWithTotals.getSummaryFaCatchType();
if (MapUtils.isEmpty(totalCatchTypeMap)) {
totalCatchTypeMap = new EnumMap<>(FaCatchTypeEnum.class);
summaryTableWithTotals.setSummaryFaCatchType(totalCatchTypeMap);
}
// Go through all the catch types and calculate total for each type
for (Map.Entry<FaCatchTypeEnum, Object> entry : catchTypeEnumMapMap.entrySet()) {
// key fishSize
FaCatchTypeEnum catchType = entry.getKey();
Object value = entry.getValue();
if (value instanceof Map) {
// check if already present
Map<String, Map<String, Double>> fishSizeMap = (Map<String, Map<String, Double>>) totalCatchTypeMap.get(catchType);
fishSizeMap = populateSpeciesPresentationMapWithTotal((Map<String, Map<String, Double>>) value, fishSizeMap);
totalCatchTypeMap.put(catchType, fishSizeMap);
}
}
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryReportHelper method populateTotalFaCatchMap.
/**
* This method processes data to calculate weights for different Catch types
* @param summaryTableWithTotals Add the calculation to this final class
* @param summaryTable process this object to calculate totals
*/
@Override
public void populateTotalFaCatchMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
Map<FaCatchTypeEnum, Object> catchTypeEnumMapMap = summaryTable.getSummaryFaCatchType();
if (MapUtils.isNotEmpty(catchTypeEnumMapMap)) {
Map<FaCatchTypeEnum, Object> totalCatchTypeMap = summaryTableWithTotals.getSummaryFaCatchType();
if (MapUtils.isEmpty(totalCatchTypeMap)) {
totalCatchTypeMap = new EnumMap<>(FaCatchTypeEnum.class);
summaryTableWithTotals.setSummaryFaCatchType(totalCatchTypeMap);
}
// Go through all the catch types and calculate total for each type
for (Map.Entry<FaCatchTypeEnum, Object> entry : catchTypeEnumMapMap.entrySet()) {
// key fishSize
FaCatchTypeEnum catchType = entry.getKey();
Object value = entry.getValue();
if (value instanceof Map) {
// check if already present
Map<String, Double> resultTotalSpeciesMap = (Map<String, Double>) totalCatchTypeMap.get(catchType);
resultTotalSpeciesMap = extractSpeciesCountMap((Map<String, Double>) value, resultTotalSpeciesMap);
totalCatchTypeMap.put(catchType, resultTotalSpeciesMap);
} else if (value instanceof Double) {
totalCatchTypeMap.put(catchType, calculateTotalValue((Double) value, (Double) totalCatchTypeMap.get(catchType)));
}
}
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class ARRCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.
@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.NOTIFICATION) {
return null;
}
CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
boolean onboardXorUnloaded = (faCatchType == FaCatchTypeEnum.ONBOARD && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.UNLOADED)) || (faCatchType == FaCatchTypeEnum.UNLOADED && !isFaCatchTypePresent(fishingActivity.getFaCatchs(), FaCatchTypeEnum.ONBOARD));
if (onboardXorUnloaded) {
handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
}
}
return catchEvolutionProgressDTO;
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class DEPCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.
@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.DECLARATION && faReportDocumentType != FaReportDocumentType.NOTIFICATION) {
return null;
}
CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
if (faCatchType == FaCatchTypeEnum.ONBOARD) {
handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
if (faReportDocumentType == FaReportDocumentType.DECLARATION) {
handleCumulatedCatchNoDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight);
}
}
}
return catchEvolutionProgressDTO;
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FaCatchTypeEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class DISCatchEvolutionProgressHandler method prepareCatchEvolutionProgressDTO.
@Override
public CatchEvolutionProgressDTO prepareCatchEvolutionProgressDTO(FishingActivityEntity fishingActivity, Map<String, Double> speciesCumulatedWeight) {
FaReportDocumentType faReportDocumentType = EnumUtils.getEnum(FaReportDocumentType.class, fishingActivity.getFaReportDocument().getTypeCode());
if (faReportDocumentType != null && faReportDocumentType != FaReportDocumentType.DECLARATION) {
return null;
}
CatchEvolutionProgressDTO catchEvolutionProgressDTO = initCatchEvolutionProgressDTO(fishingActivity, faReportDocumentType, speciesCumulatedWeight);
for (FaCatchEntity faCatch : fishingActivity.getFaCatchs()) {
FaCatchTypeEnum faCatchType = EnumUtils.getEnum(FaCatchTypeEnum.class, faCatch.getTypeCode());
if (faCatchType == FaCatchTypeEnum.DEMINIMIS || faCatchType == FaCatchTypeEnum.DISCARDED || faCatchType == FaCatchTypeEnum.UNLOADED) {
handleOnboardCatch(faCatch, catchEvolutionProgressDTO);
handleCumulatedCatchWithDeletion(faCatch, catchEvolutionProgressDTO, speciesCumulatedWeight, Arrays.asList(FaCatchTypeEnum.DEMINIMIS, FaCatchTypeEnum.DISCARDED, FaCatchTypeEnum.UNLOADED));
}
}
return catchEvolutionProgressDTO;
}
Aggregations