use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getSpeciesCode.
protected List<String> getSpeciesCode(FishingActivityEntity entity) {
if (entity == null || entity.getFaCatchs() == null) {
return Collections.emptyList();
}
HashSet<String> speciesCode = new HashSet<>();
Set<FaCatchEntity> faCatchList = entity.getFaCatchs();
for (FaCatchEntity faCatch : faCatchList) {
speciesCode.add(faCatch.getSpeciesCode());
getSpeciesCodeFromAapProduct(faCatch, speciesCode);
}
speciesCode.remove(null);
return new ArrayList<>(speciesCode);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getFaCatchEntities.
protected Set<FaCatchEntity> getFaCatchEntities(List<FACatch> faCatches, FishingActivityEntity fishingActivityEntity) {
if (faCatches == null || faCatches.isEmpty()) {
return Collections.emptySet();
}
Set<FaCatchEntity> faCatchEntities = new HashSet<>();
for (FACatch faCatch : faCatches) {
FaCatchEntity faCatchEntity = FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
faCatchEntity.setFishingActivity(fishingActivityEntity);
faCatchEntity.setGearTypeCode(extractFishingGearTypeCode(faCatchEntity.getFishingGears()));
faCatchEntity.setPresentation(extractPresentation(faCatchEntity.getAapProcesses()));
faCatchEntities.add(mapFluxLocationSchemeIds(faCatch, faCatchEntity));
}
return faCatchEntities;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchesProcessorMapper method calculateTotalsAndFillSubgroups.
/**
* Subgroups by BMS and LSC and :
* Calculates the total and fills all the details related to each subgroup.
*
* @param groupCatchList
* @param groupDto
*/
private static void calculateTotalsAndFillSubgroups(List<FaCatchEntity> groupCatchList, FaCatchGroupDto groupDto) {
Map<String, FaCatchGroupDetailsDto> groupingDetailsMap = groupDto.getGroupingDetails();
FaCatchGroupDetailsDto lscGroupDetailsDto = new FaCatchGroupDetailsDto();
FaCatchGroupDetailsDto bmsGroupDetailsDto = new FaCatchGroupDetailsDto();
// Weight and units totals
Double lscGroupTotalWeight = null;
Double lscGroupTotalUnits = null;
Double bmsGroupTotalWeight = null;
Double bmsGroupTotalUnits = null;
for (FaCatchEntity entity : groupCatchList) {
Double calculatedWeightMeasure = entity.getCalculatedWeightMeasure();
if (calculatedWeightMeasure == null) {
calculatedWeightMeasure = extractLiveWeight(entity.getAapProcesses());
}
Double unitQuantity = entity.getUnitQuantity();
String fishClassCode = entity.getFishClassCode() != null ? entity.getFishClassCode() : StringUtils.EMPTY;
switch(fishClassCode) {
case LSC:
// Weight and Units calculation
lscGroupTotalWeight = Utils.addDoubles(calculatedWeightMeasure, lscGroupTotalWeight);
lscGroupTotalUnits = Utils.addDoubles(unitQuantity, lscGroupTotalUnits);
fillDetailsForSubGroup(lscGroupDetailsDto, entity);
break;
case BMS:
// Weight and Units calculation
bmsGroupTotalWeight = Utils.addDoubles(calculatedWeightMeasure, bmsGroupTotalWeight);
bmsGroupTotalUnits = Utils.addDoubles(unitQuantity, bmsGroupTotalUnits);
fillDetailsForSubGroup(bmsGroupDetailsDto, entity);
break;
default:
log.error("While constructing Fa Catch Section of the view the FaCatchEntity with id : " + entity.getId() + " is neither LSC or BMS!");
}
}
setWeightsForSubGroup(groupDto, lscGroupDetailsDto, bmsGroupDetailsDto, lscGroupTotalWeight, lscGroupTotalUnits, bmsGroupTotalWeight, bmsGroupTotalUnits);
// Put the 2 subgroup properties in the groupingDetailsMap (property of FaCatchGroupDto).
List<FluxLocationDto> lscGroupDetailsDtoSpecifiedFluxLocations = lscGroupDetailsDto.getSpecifiedFluxLocations();
// remove duplicates
lscGroupDetailsDto.setSpecifiedFluxLocations(new ArrayList<>(new LinkedHashSet<>(lscGroupDetailsDtoSpecifiedFluxLocations)));
List<FluxLocationDto> bmsGroupDetailsDtoSpecifiedFluxLocations = bmsGroupDetailsDto.getSpecifiedFluxLocations();
// remove duplicates
bmsGroupDetailsDto.setSpecifiedFluxLocations(new ArrayList<>(new LinkedHashSet<>(bmsGroupDetailsDtoSpecifiedFluxLocations)));
groupingDetailsMap.put(BMS, bmsGroupDetailsDto);
groupingDetailsMap.put(LSC, lscGroupDetailsDto);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getQuantity.
/**
* This method will calculate sum of all the weights of FACatches
* @param entity
* @return
*/
protected Double getQuantity(FishingActivityEntity entity) {
if (entity == null || entity.getFaCatchs() == null) {
return new Double(0);
}
Double quantity = new Double(0);
Set<FaCatchEntity> faCatchList = entity.getFaCatchs();
for (FaCatchEntity faCatch : faCatchList) {
if (faCatch.getCalculatedWeightMeasure() != null)
quantity = quantity + faCatch.getCalculatedWeightMeasure();
getQuantityFromAapProduct(faCatch, quantity);
}
return quantity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchesProcessorMapper method mapFaCatchListToCatchGroupDto.
/**
* Maps a list of CatchEntities (rappresenting a froup) to a FaCatchGroupDto;
*
* @param groupCatchList
* @return
*/
private static FaCatchGroupDto mapFaCatchListToCatchGroupDto(List<FaCatchEntity> groupCatchList) {
FaCatchGroupDto groupDto = new FaCatchGroupDto();
FaCatchEntity catchEntity = groupCatchList.get(0);
// Set primary properties on groupDto
groupDto.setType(catchEntity.getTypeCode());
groupDto.setSpecies(catchEntity.getSpeciesCode());
// Fill the denomination location part of the GroupDto.
groupDto.setLocations(FaCatchGroupMapper.INSTANCE.mapFaCatchEntityToDenominationLocation(catchEntity));
// calculate Totals And Fill Soecified Locations and Gears Per each Subgroup (subgrupped on BMS/LSC)
calculateTotalsAndFillSubgroups(groupCatchList, groupDto);
return groupDto;
}
Aggregations