use of java.util.EnumMap 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 java.util.EnumMap 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 java.util.EnumMap 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 java.util.EnumMap in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityRequestMapper method extractFiltersAsMap.
/**
* Some search Filters expect only single value. Others support multiple values for search.
* This method sorts Filter list and separates filters with single values and return the map with its value.
* @param filterTypes
* @return Map<SearchFilter,String> Map of SearchFilter and its value
* @throws ServiceException
*/
private static Map<SearchFilter, String> extractFiltersAsMap(List<SingleValueTypeFilter> filterTypes) throws ServiceException {
Set<SearchFilter> filtersWithMultipleValues = FilterMap.getFiltersWhichSupportMultipleValues();
Map<SearchFilter, String> searchMap = new EnumMap<>(SearchFilter.class);
for (SingleValueTypeFilter filterType : filterTypes) {
SearchFilter filter = filterType.getKey();
if (filtersWithMultipleValues.contains(filter)) {
throw new ServiceException("Filter provided with Single Value. Application Expects values as List for the Filter :" + filter);
}
searchMap.put(filterType.getKey(), filterType.getValue());
}
return searchMap;
}
use of java.util.EnumMap in project EnderIO by SleepyTrousers.
the class ReservoirBlockRenderMapper method mapOverlayLayer.
@Override
@SideOnly(Side.CLIENT)
public EnumMap<EnumFacing, EnumIOMode> mapOverlayLayer(@Nonnull IBlockStateWrapper state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, boolean isPainted) {
TileEntity tileEntity = state.getTileEntity();
if ((tileEntity instanceof TileReservoir) && ((TileReservoir) tileEntity).isAutoEject()) {
EnumMap<EnumFacing, EnumIOMode> result = new EnumMap<EnumFacing, EnumIOMode>(EnumFacing.class);
for (NNIterator<EnumFacing> itr = NNList.FACING.fastIterator(); itr.hasNext(); ) {
EnumFacing face = itr.next();
IBlockState neighborState = world.getBlockState(pos.offset(face));
if (!isSameKind(state, neighborState)) {
result.put(face, EnumIOMode.RESERVOIR);
}
}
return result.isEmpty() ? null : result;
}
return null;
}
Aggregations