use of eu.europa.ec.fisheries.ers.service.dto.view.FluxLocationDto 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.service.dto.view.FluxLocationDto in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchesProcessorMapper method fillSpecifiedAndDestinationLocationsInGroupDetails.
/**
* Fills the locations on FaCatchGroupDetailsDto DTO.
*
* @param fluxLocations
* @param groupDetailsDto
*/
private static void fillSpecifiedAndDestinationLocationsInGroupDetails(Set<FluxLocationEntity> fluxLocations, FaCatchGroupDetailsDto groupDetailsDto) {
if (CollectionUtils.isEmpty(fluxLocations)) {
return;
}
List<DestinationLocationDto> destLocDtoList = groupDetailsDto.getDestinationLocation();
List<FluxLocationDto> specifiedFluxLocDto = groupDetailsDto.getSpecifiedFluxLocations();
for (FluxLocationEntity actLoc : fluxLocations) {
String fluxLocationType = actLoc.getFluxLocationType();
if (StringUtils.equals(fluxLocationType, FluxLocationCatchTypeEnum.FA_CATCH_DESTINATION.getType())) {
destLocDtoList.add(new DestinationLocationDto(actLoc.getFluxLocationIdentifier(), actLoc.getCountryId(), actLoc.getName()));
} else if (StringUtils.equals(fluxLocationType, FluxLocationCatchTypeEnum.FA_CATCH_SPECIFIED.getType())) {
specifiedFluxLocDto.add(FluxLocationMapper.INSTANCE.mapEntityToFluxLocationDto(actLoc));
}
}
groupDetailsDto.setDestinationLocation(destLocDtoList);
groupDetailsDto.setSpecifiedFluxLocations(specifiedFluxLocDto);
}
use of eu.europa.ec.fisheries.ers.service.dto.view.FluxLocationDto in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingOperationViewMapper method mapFaEntityToFaDto.
@Override
public FishingActivityViewDTO mapFaEntityToFaDto(FishingActivityEntity faEntity) {
FishingActivityViewDTO viewDTO = new FishingActivityViewDTO();
ActivityDetailsDto detailsDto = mapActivityDetails(faEntity);
detailsDto.setOccurrence(faEntity.getOccurence());
detailsDto.setVesselActivity(faEntity.getVesselActivityCode());
if (faEntity.getOperationsQuantity() != null && faEntity.getOperationsQuantity().getValue() != null) {
detailsDto.setNrOfOperation(faEntity.getOperationsQuantity().getValue().intValue());
}
detailsDto.setFisheryType(faEntity.getFisheryTypeCode());
detailsDto.setSpeciesTarget(faEntity.getSpeciesTargetCode());
Set<FishingActivityIdentifierEntity> fishingActivityIdentifiers = faEntity.getFishingActivityIdentifiers();
detailsDto.setIdentifiers(FishingActivityIdentifierMapper.INSTANCE.mapToIdentifierDTOSet(fishingActivityIdentifiers));
detailsDto.setFishingTime(this.calculateFishingTime(faEntity.getDelimitedPeriods()));
viewDTO.setActivityDetails(detailsDto);
viewDTO.setGears(this.getGearsFromEntity(faEntity.getFishingGears()));
viewDTO.setReportDetails(this.getReportDocsFromEntity(faEntity.getFaReportDocument()));
viewDTO.setCatches(this.mapCatchesToGroupDto(faEntity));
viewDTO.setProcessingProducts(this.getProcessingProductsByFaCatches(faEntity.getFaCatchs()));
viewDTO.setGearProblems(GearShotRetrievalTileMapper.INSTANCE.mapGearProblemsToGearsDto(faEntity.getGearProblems()));
viewDTO.setGearShotRetrievalList(GearShotRetrievalTileMapperImpl.INSTANCE.mapFromRelatedFishingActivities(faEntity));
Set<FluxLocationDto> fluxLocationDtos = mapFromFluxLocation(faEntity.getFluxLocations());
viewDTO.setLocations(fluxLocationDtos);
viewDTO.setVesselDetails(getVesselDetailsDTO(faEntity));
return viewDTO;
}
use of eu.europa.ec.fisheries.ers.service.dto.view.FluxLocationDto in project UVMS-ActivityModule-APP by UnionVMS.
the class BaseActivityViewMapper method getSortedAreas.
public AreaDto getSortedAreas(FishingActivityEntity faEntity, Comparator<FluxLocationDto> comparator) {
AreaDto areaDto = getAreas(faEntity);
final List<FluxLocationDto> fluxLocationDtos = new ArrayList<>(areaDto.getFluxLocations());
TreeSet<FluxLocationDto> fluxLocationDtoTreeSet = new TreeSet<FluxLocationDto>(comparator);
fluxLocationDtoTreeSet.addAll(fluxLocationDtos);
areaDto.setFluxLocations(fluxLocationDtoTreeSet);
return areaDto;
}
use of eu.europa.ec.fisheries.ers.service.dto.view.FluxLocationDto in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method addPortDescriptions.
private void addPortDescriptions(FishingActivityViewDTO fishingActivityViewDTO, String fluxLocationIdSchemeId) {
if (fishingActivityViewDTO == null || StringUtils.isBlank(fluxLocationIdSchemeId)) {
return;
}
final String ACRONYM = "LOCATION";
String filter = null;
final List<String> columnsList = new ArrayList<String>(Arrays.asList("code"));
Integer nrOfResults = 1;
if (CollectionUtils.isNotEmpty(fishingActivityViewDTO.getLocations())) {
for (FluxLocationDto fluxLocationDto : fishingActivityViewDTO.getLocations()) {
if (fluxLocationIdSchemeId.equals(fluxLocationDto.getFluxLocationIdentifierSchemeId())) {
try {
filter = fluxLocationDto.getFluxLocationIdentifier();
List<String> codeDescriptions = mdrModuleService.getAcronymFromMdr(ACRONYM, filter, columnsList, nrOfResults, "description").get("description");
String codeDescription = codeDescriptions.get(0);
fluxLocationDto.setPortDescription(codeDescription);
} catch (ServiceException e) {
log.error("Error while trying to set port description on FluxLocationDto.", e);
} catch (IndexOutOfBoundsException iobe) {
log.error("Error while trying to set port description on FluxLocationDto! Description for code: " + fluxLocationDto.getTypeCode() + " doesn't exist", iobe);
}
}
}
}
}
Aggregations