use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishSizeClassEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryPresentationHelper method populateTotalFishSizeMap.
@Override
public void populateTotalFishSizeMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
Map<FishSizeClassEnum, Object> fishSizeClassEnumMap = summaryTable.getSummaryFishSize();
if (MapUtils.isEmpty(fishSizeClassEnumMap)) {
return;
}
Map<FishSizeClassEnum, Object> totalFishSizeSpeciesMap = summaryTableWithTotals.getSummaryFishSize();
if (MapUtils.isEmpty(totalFishSizeSpeciesMap)) {
totalFishSizeSpeciesMap = new EnumMap<>(FishSizeClassEnum.class);
summaryTableWithTotals.setSummaryFishSize(totalFishSizeSpeciesMap);
}
// Go through all the Fish classes and calculate total for each fishclass
for (Map.Entry<FishSizeClassEnum, Object> entry : fishSizeClassEnumMap.entrySet()) {
// key fishSize
FishSizeClassEnum fishSize = entry.getKey();
Object value = entry.getValue();
// Value will be Double if species are not present as grouping criteria Else it will be map of Species and its count
if (value instanceof Map) {
// check if already present
Map<String, Map<String, Double>> fishSizeMap = (Map<String, Map<String, Double>>) totalFishSizeSpeciesMap.get(fishSize);
fishSizeMap = populateSpeciesPresentationMapWithTotal((Map<String, Map<String, Double>>) value, fishSizeMap);
totalFishSizeSpeciesMap.put(fishSize, fishSizeMap);
}
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishSizeClassEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryReportHelper method populateTotalFishSizeMap.
/**
* This method will calculate totals for FishSize section
* @param summaryTableWithTotals Add the calculation to this final class
* @param summaryTable process this object to calculate totals
*/
@Override
public void populateTotalFishSizeMap(SummaryTableDTO summaryTableWithTotals, SummaryTableDTO summaryTable) {
Map<FishSizeClassEnum, Object> fishSizeClassEnumMap = summaryTable.getSummaryFishSize();
if (MapUtils.isEmpty(fishSizeClassEnumMap)) {
return;
}
Map<FishSizeClassEnum, Object> totalFishSizeSpeciesMap = summaryTableWithTotals.getSummaryFishSize();
if (MapUtils.isEmpty(totalFishSizeSpeciesMap)) {
totalFishSizeSpeciesMap = new EnumMap<>(FishSizeClassEnum.class);
summaryTableWithTotals.setSummaryFishSize(totalFishSizeSpeciesMap);
}
// Go through all the Fish classes and calculate total for each fishclass
for (Map.Entry<FishSizeClassEnum, Object> entry : fishSizeClassEnumMap.entrySet()) {
// key fishSize
FishSizeClassEnum fishSize = entry.getKey();
Object value = entry.getValue();
// Value will be Double if species are not present as grouping criteria Else it will be map of Species and its count
if (value instanceof Map) {
// check if already present
Map<String, Double> totalSpeciesMap = (Map<String, Double>) totalFishSizeSpeciesMap.get(fishSize);
totalSpeciesMap = extractSpeciesCountMap((Map<String, Double>) value, totalSpeciesMap);
totalFishSizeSpeciesMap.put(fishSize, totalSpeciesMap);
} else if (value instanceof Double) {
totalFishSizeSpeciesMap.put(fishSize, calculateTotalValue((Double) value, (Double) totalFishSizeSpeciesMap.get(fishSize)));
}
}
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishSizeClassEnum in project UVMS-ActivityModule-APP by UnionVMS.
the class FACatchSummaryMapper method getSummaryFishSizeList.
protected List<SummaryFishSize> getSummaryFishSizeList(Map<FishSizeClassEnum, Object> summaryFishSizeMap) {
if (MapUtils.isEmpty(summaryFishSizeMap)) {
return new ArrayList<>();
}
List<SummaryFishSize> summaryFishSizes = new ArrayList<>();
for (Map.Entry<FishSizeClassEnum, Object> entry : summaryFishSizeMap.entrySet()) {
SummaryFishSize summaryFishSize = new SummaryFishSize();
summaryFishSize.setFishSize(entry.getKey());
Object value = entry.getValue();
if (value instanceof Map) {
summaryFishSize.setSpecies(getSpeciesCounts((Map<String, Double>) value));
} else if (value instanceof Double) {
summaryFishSize.setFishSizeCount((Double) value);
}
summaryFishSizes.add(summaryFishSize);
}
log.debug("SummaryFishSize List is created");
return summaryFishSizes;
}
Aggregations