Search in sources :

Example 1 with FishingActivity

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity in project UVMS-ActivityModule-APP by UnionVMS.

the class MapperUtil method getStandardFishingActivity.

private static FishingActivity getStandardFishingActivity() {
    List<IDType> ids = Arrays.asList(getIdType("Id_1", "fhr574fh-thrud754-kgitjf754-gjtufe89"));
    CodeType typeCode = getCodeType("FISHING_OPERATION", "FLUX_FA_TYPE");
    DateTimeType occurrenceDateTime = getDateTimeType("2016-07-01 11:15:00");
    CodeType reasonCode = getCodeType("Reason_code_1", "FA_REASON_DEPARTURE");
    CodeType vesselRelatedActivityCode = getCodeType("Vessel activity 1", "58thft-58fjd8-gt85eje-hjgute8");
    CodeType fisheryTypeCode = getCodeType("Fishing_Type_code 1", "FA_FISHERY");
    CodeType speciesTargetCode = getCodeType("Species code 1", "FAO_SPECIES");
    QuantityType operationsQuantity = getQuantityType(100);
    MeasureType fishingDurationMeasure = getMeasureType(500, "C62", "4hr2yf0-t583thf-6jgttue8-6jtie844");
    List<FLAPDocument> specifiedFLAPDocument = Arrays.asList(getFlapDocument());
    VesselStorageCharacteristic sourceVesselStorageCharacteristic = getVesselStorageCharacteristic();
    VesselStorageCharacteristic destinationVesselStorageCharacteristic = getVesselStorageCharacteristic();
    List<FACatch> specifiedFACatches = Arrays.asList(getFaCatch());
    List<FLUXLocation> relatedFLUXLocations = Arrays.asList(getFluxLocation());
    List<GearProblem> specifiedGearProblems = Arrays.asList(getGearProblem());
    List<FLUXCharacteristic> specifiedFLUXCharacteristics = Arrays.asList(getFluxCharacteristics());
    List<FishingGear> specifiedFishingGears = Arrays.asList(getFishingGear());
    List<DelimitedPeriod> specifiedDelimitedPeriods = Arrays.asList(getDelimitedPeriod());
    FishingTrip specifiedFishingTrip = getFishingTrip();
    List<VesselTransportMeans> relatedVesselTransportMeans = Arrays.asList(getVesselTransportMeans());
    FishingActivity fishingActivity = new FishingActivity(ids, typeCode, occurrenceDateTime, reasonCode, vesselRelatedActivityCode, fisheryTypeCode, speciesTargetCode, operationsQuantity, fishingDurationMeasure, specifiedFACatches, relatedFLUXLocations, specifiedGearProblems, specifiedFLUXCharacteristics, specifiedFishingGears, sourceVesselStorageCharacteristic, destinationVesselStorageCharacteristic, null, specifiedFLAPDocument, specifiedDelimitedPeriods, specifiedFishingTrip, relatedVesselTransportMeans);
    return fishingActivity;
}
Also used : DelimitedPeriod(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod) FLAPDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLAPDocument) FishingGear(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingGear) MeasureType(un.unece.uncefact.data.standard.unqualifieddatatype._20.MeasureType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) GearProblem(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.GearProblem) FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) VesselStorageCharacteristic(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselStorageCharacteristic) FLUXCharacteristic(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXCharacteristic) VesselTransportMeans(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) QuantityType(un.unece.uncefact.data.standard.unqualifieddatatype._20.QuantityType) FLUXLocation(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXLocation) FishingTrip(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingTrip) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) FACatch(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch)

Example 2 with FishingActivity

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity in project UVMS-ActivityModule-APP by UnionVMS.

the class MapperUtil method getFishingActivity.

public static FishingActivity getFishingActivity() {
    FishingActivity fishingActivity = getStandardFishingActivity();
    List<FishingActivity> relatedFishingActivities = Arrays.asList(getStandardFishingActivity());
    fishingActivity.setRelatedFishingActivities(relatedFishingActivities);
    return fishingActivity;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)

Example 3 with FishingActivity

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity in project UVMS-ActivityModule-APP by UnionVMS.

the class FaReportDocumentMapper method getFishingActivityEntities.

protected Set<FishingActivityEntity> getFishingActivityEntities(List<FishingActivity> fishingActivities, FaReportDocumentEntity faReportDocumentEntity) {
    if (CollectionUtils.isEmpty(fishingActivities)) {
        return Collections.emptySet();
    }
    Set<FishingActivityEntity> fishingActivityEntities = new HashSet<>();
    for (FishingActivity fishingActivity : fishingActivities) {
        FishingActivityEntity fishingActivityEntity = FishingActivityMapper.INSTANCE.mapToFishingActivityEntity(fishingActivity, faReportDocumentEntity, new FishingActivityEntity());
        fishingActivityEntities.add(fishingActivityEntity);
        if (fishingActivityEntity.getAllRelatedFishingActivities() != null && !fishingActivityEntity.getAllRelatedFishingActivities().isEmpty()) {
            fishingActivityEntities.addAll(fishingActivityEntity.getAllRelatedFishingActivities());
        }
    }
    return fishingActivityEntities;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Example 4 with FishingActivity

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapper method getAllRelatedFishingActivities.

protected Set<FishingActivityEntity> getAllRelatedFishingActivities(List<FishingActivity> fishingActivity, FaReportDocumentEntity faReportDocumentEntity, FishingActivityEntity parentFishingActivity) {
    if (fishingActivity == null || fishingActivity.isEmpty()) {
        return Collections.emptySet();
    }
    Set<FishingActivityEntity> relatedFishingActivityEntities = new HashSet<>();
    for (FishingActivity relatedFishingActivity : fishingActivity) {
        FishingActivityEntity relatedFishingActivityEntity = FishingActivityMapper.INSTANCE.mapToFishingActivityEntity(relatedFishingActivity, faReportDocumentEntity, new FishingActivityEntity());
        relatedFishingActivityEntity.setRelatedFishingActivity(parentFishingActivity);
        relatedFishingActivityEntities.add(relatedFishingActivityEntity);
    }
    return relatedFishingActivityEntities;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Example 5 with FishingActivity

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapper method getCalculatedStartTime.

protected DateTimeType getCalculatedStartTime(FishingActivity fishingActivity) {
    if (fishingActivity == null)
        return null;
    DateTimeType dateTimeType = null;
    if (fishingActivity.getOccurrenceDateTime() != null)
        return fishingActivity.getOccurrenceDateTime();
    if (CollectionUtils.isNotEmpty(fishingActivity.getSpecifiedDelimitedPeriods())) {
        List<DelimitedPeriod> delimitedPeriodEntities = fishingActivity.getSpecifiedDelimitedPeriods();
        dateTimeType = delimitedPeriodEntities.iterator().next().getStartDateTime();
        if (dateTimeType != null) {
            return dateTimeType;
        }
    }
    // We reached till this point of code means FishingActivity has neither occurrence date or startDate for DelimitedPeriod.
    // In such cases, we need to check if its subactivities have date mentioned.
    // If yes, then take the first subactivity occurrence date and consider it as start date for parent fishing activity
    List<FishingActivity> relatedFishingActivities = fishingActivity.getRelatedFishingActivities();
    if (CollectionUtils.isNotEmpty(relatedFishingActivities)) {
        for (FishingActivity subFishingActivity : relatedFishingActivities) {
            if (subFishingActivity.getOccurrenceDateTime() != null || (CollectionUtils.isNotEmpty(fishingActivity.getSpecifiedDelimitedPeriods()) && fishingActivity.getSpecifiedDelimitedPeriods().iterator().next().getStartDateTime() != null)) {
                dateTimeType = subFishingActivity.getOccurrenceDateTime();
                if (dateTimeType == null) {
                    dateTimeType = fishingActivity.getSpecifiedDelimitedPeriods().iterator().next().getStartDateTime();
                }
                return dateTimeType;
            }
        }
    }
    return null;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) DelimitedPeriod(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod)

Aggregations

FishingActivity (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)9 CodeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType)7 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)5 VesselTransportMeans (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans)4 DateTimeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType)4 HashSet (java.util.HashSet)3 VesselStorageCharacteristic (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselStorageCharacteristic)3 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)2 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 DelimitedPeriod (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod)2 FLUXCharacteristic (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXCharacteristic)2 FishingTrip (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingTrip)2 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)2 MeasureType (un.unece.uncefact.data.standard.unqualifieddatatype._20.MeasureType)2 QuantityType (un.unece.uncefact.data.standard.unqualifieddatatype._20.QuantityType)2 DelimitedPeriodEntity (eu.europa.ec.fisheries.ers.fa.entities.DelimitedPeriodEntity)1 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1