use of eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchMapperTest method testFaCatchMapper.
@Test
public void testFaCatchMapper() {
FACatch faCatch = MapperUtil.getFaCatch();
FaCatchEntity faCatchEntity = FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
assertFaCatchFields(faCatch, faCatchEntity);
assertNull(faCatchEntity.getFishingActivity());
assertNotNull(faCatchEntity.getAapProcesses());
AapProcessEntity aapProcessEntity = faCatchEntity.getAapProcesses().iterator().next();
assertNotNull(aapProcessEntity);
assertFaCatchFields(faCatch, aapProcessEntity.getFaCatch());
assertNotNull(faCatchEntity.getAapStocks());
AapStockEntity aapStockEntity = faCatchEntity.getAapStocks().iterator().next();
assertNotNull(aapStockEntity);
assertFaCatchFields(faCatch, aapStockEntity.getFaCatch());
assertNotNull(faCatchEntity.getSizeDistribution());
assertFaCatchFields(faCatch, faCatchEntity.getSizeDistribution().getFaCatch());
assertNotNull(faCatchEntity.getFishingGears());
FishingGearEntity fishingGearEntity = faCatchEntity.getFishingGears().iterator().next();
assertNotNull(fishingGearEntity);
assertFaCatchFields(faCatch, fishingGearEntity.getFaCatch());
assertNotNull(faCatchEntity.getFishingTrips());
FishingTripEntity fishingTripEntity = faCatchEntity.getFishingTrips().iterator().next();
assertNotNull(fishingTripEntity);
assertFaCatchFields(faCatch, fishingTripEntity.getFaCatch());
assertNotNull(faCatchEntity.getFluxCharacteristics());
FluxCharacteristicEntity fluxCharacteristicEntity = faCatchEntity.getFluxCharacteristics().iterator().next();
assertNotNull(fluxCharacteristicEntity);
assertFaCatchFields(faCatch, fluxCharacteristicEntity.getFaCatch());
assertNotNull(faCatchEntity.getFluxLocations());
FluxLocationEntity fluxLocationEntity = faCatchEntity.getFluxLocations().iterator().next();
assertNotNull(fluxLocationEntity);
assertFaCatchFields(faCatch, fluxLocationEntity.getFaCatch());
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchMapper method getFluxCharacteristicEntities.
protected Set<FluxCharacteristicEntity> getFluxCharacteristicEntities(List<FLUXCharacteristic> fluxCharacteristics, FaCatchEntity faCatchEntity) {
if (fluxCharacteristics == null || fluxCharacteristics.isEmpty()) {
return Collections.emptySet();
}
Set<FluxCharacteristicEntity> fluxCharacteristicEntities = new HashSet<>();
for (FLUXCharacteristic fluxCharacteristic : fluxCharacteristics) {
FluxCharacteristicEntity fluxCharacteristicEntity = FluxCharacteristicsMapper.INSTANCE.mapToFluxCharEntity(fluxCharacteristic);
fluxCharacteristicEntity.setFaCatch(faCatchEntity);
fluxCharacteristicEntities.add(fluxCharacteristicEntity);
}
return fluxCharacteristicEntities;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getFluxCharacteristicsEntities.
protected Set<FluxCharacteristicEntity> getFluxCharacteristicsEntities(List<FLUXCharacteristic> fluxCharacteristics, FishingActivityEntity fishingActivityEntity) {
if (fluxCharacteristics == null || fluxCharacteristics.isEmpty()) {
return Collections.emptySet();
}
Set<FluxCharacteristicEntity> fluxCharacteristicEntities = new HashSet<>();
for (FLUXCharacteristic fluxCharacteristic : fluxCharacteristics) {
FluxCharacteristicEntity fluxCharacteristicEntity = FluxCharacteristicsMapper.INSTANCE.mapToFluxCharEntity(fluxCharacteristic);
fluxCharacteristicEntity.setFishingActivity(fishingActivityEntity);
fluxCharacteristicEntities.add(fluxCharacteristicEntity);
}
return fluxCharacteristicEntities;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class BaseActivityViewMapper method getFluxCharacteristicsTypeCodeValue.
protected Map<String, String> getFluxCharacteristicsTypeCodeValue(Set<FluxCharacteristicEntity> fluxCharacteristics) {
if (fluxCharacteristics == null) {
return Collections.emptyMap();
}
Map<String, String> characMap = new HashMap<>();
for (FluxCharacteristicEntity fluxCharacteristic : fluxCharacteristics) {
String value = null;
if (fluxCharacteristic.getValueMeasure() != null) {
value = String.valueOf(fluxCharacteristic.getValueMeasure());
} else if (fluxCharacteristic.getValueDateTime() != null) {
value = DateUtils.dateToString(fluxCharacteristic.getValueDateTime());
} else if (fluxCharacteristic.getValueIndicator() != null) {
value = fluxCharacteristic.getValueIndicator();
} else if (fluxCharacteristic.getValueCode() != null) {
value = fluxCharacteristic.getValueCode();
} else if (fluxCharacteristic.getValueText() != null) {
value = fluxCharacteristic.getValueText();
} else if (fluxCharacteristic.getValueQuantity() != null) {
value = String.valueOf(fluxCharacteristic.getValueQuantity());
}
characMap.put(fluxCharacteristic.getTypeCode(), value);
}
return characMap;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEntityToModelMapper method mapSpecifiedFLUXCharacteristics.
private void mapSpecifiedFLUXCharacteristics(FishingActivity fishingActivity, Set<FluxCharacteristicEntity> fluxCharacteristics) {
if (CollectionUtils.isNotEmpty(fluxCharacteristics)) {
List<FLUXCharacteristic> fluxCharacteristicList = new ArrayList<>();
for (FluxCharacteristicEntity source : fluxCharacteristics) {
FLUXCharacteristic target = new FLUXCharacteristic();
mapPurposeCode(target, source);
mapValueCode(target, source);
mapValueDateTime(target, source);
mapValueIndicator(target, source);
mapValueQuantity(target, source);
mapValueMeasure(target, source);
mapDescriptions(target, source);
mapValues(target, source);
fluxCharacteristicList.add(target);
}
fishingActivity.setSpecifiedFLUXCharacteristics(fluxCharacteristicList);
}
}
Aggregations