use of eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getCronologyOfFishingTrip.
/**
* {@inheritDoc}
*/
@Override
public CronologyTripDTO getCronologyOfFishingTrip(String tripId, Integer count) throws ServiceException {
// Find the latest Vessel for the Trip for finding the trip of that vessel
List<VesselIdentifierEntity> latestVesselIdentifiers = vesselIdentifierDao.getLatestVesselIdByTrip(tripId);
CronologyTripDTO cronologyTripDTO = new CronologyTripDTO();
cronologyTripDTO.setCurrentTrip(getCurrentTrip(latestVesselIdentifiers));
cronologyTripDTO.setSelectedTrip(tripId);
List<String> previousTrips = new ArrayList<>(getPreviousTrips(tripId, count, latestVesselIdentifiers));
List<String> nextTrips = new ArrayList<>(getNextTrips(tripId, count, latestVesselIdentifiers));
Map<String, Integer> countMap = calculateTripCounts(count, previousTrips.size(), nextTrips.size());
log.info("Number of previous record to find : " + countMap.get(PREVIOUS));
log.info("Number of next record to find : " + countMap.get(NEXT));
cronologyTripDTO.setPreviousTrips(previousTrips.subList(previousTrips.size() - countMap.get(PREVIOUS), previousTrips.size()));
cronologyTripDTO.setNextTrips(nextTrips.subList(0, countMap.get(NEXT)));
return cronologyTripDTO;
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getPreviousTrips.
private Set<String> getPreviousTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
Set<String> tripIds = new LinkedHashSet<>();
if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
// FIXME
List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getPreviousTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
for (FishingTripIdentifierEntity identifiers : identifierEntities) {
tripIds.add(identifiers.getTripId());
}
}
}
log.debug("Previous Trips : " + tripIds);
return tripIds;
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class VesselIdentifierMapperTest method testMapToIdentifierDtoSet.
@Test
public void testMapToIdentifierDtoSet() {
VesselIdentifierEntity entity = builder().vesselIdentifierSchemeId("CFR").vesselIdentifierId("schemeId").build();
Set<AssetIdentifierDto> identifierDtos = INSTANCE.mapToIdentifierDotSet(asSet(entity));
assertEquals(1, identifierDtos.size());
assertEquals("schemeId", identifierDtos.iterator().next().getFaIdentifierId());
assertEquals(VesselIdentifierSchemeIdEnum.CFR, identifierDtos.iterator().next().getIdentifierSchemeId());
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripIdWithGeometryMapper method getVesselIdListsForFishingActivity.
protected List<VesselIdentifierType> getVesselIdListsForFishingActivity(List<FishingActivityEntity> fishingActivities) {
if (CollectionUtils.isEmpty(fishingActivities) || fishingActivities.get(fishingActivities.size() - 1) == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument() == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument().getVesselTransportMeans() == null) {
return Collections.emptyList();
}
int totalFishingActivityCount = fishingActivities.size();
FishingActivityEntity fishingActivityEntity = fishingActivities.get(totalFishingActivityCount - 1);
Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = fishingActivityEntity.getFaReportDocument().getVesselTransportMeans();
if (CollectionUtils.isEmpty(vesselTransportMeansEntityList) || CollectionUtils.isEmpty(vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers())) {
return Collections.emptyList();
}
Set<VesselIdentifierEntity> vesselIdentifierEntities = vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers();
List<VesselIdentifierType> vesselIdentifierTypes = new ArrayList<>();
if (CollectionUtils.isNotEmpty(vesselIdentifierEntities)) {
for (VesselIdentifierEntity vesselIdentifierEntity : vesselIdentifierEntities) {
VesselIdentifierType vesselIdentifierType = new VesselIdentifierType();
vesselIdentifierType.setKey(VesselIdentifierSchemeIdEnum.valueOf(vesselIdentifierEntity.getVesselIdentifierSchemeId()));
vesselIdentifierType.setValue(vesselIdentifierEntity.getVesselIdentifierId());
vesselIdentifierTypes.add(vesselIdentifierType);
}
}
return vesselIdentifierTypes;
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class AssetModuleServiceBean method createAssetListQuery.
private AssetListQuery createAssetListQuery(Collection<VesselIdentifierEntity> vesselIdentifiers) {
AssetListQuery assetListQuery = new AssetListQuery();
// Set asset list criteria
AssetListCriteria assetListCriteria = new AssetListCriteria();
for (VesselIdentifierEntity identifier : vesselIdentifiers) {
VesselTypeAssetQueryEnum queryEnum = VesselTypeAssetQueryEnum.getVesselTypeAssetQueryEnum(identifier.getVesselIdentifierSchemeId());
if (queryEnum != null && queryEnum.getConfigSearchField() != null && StringUtils.isNotEmpty(identifier.getVesselIdentifierId())) {
AssetListCriteriaPair criteriaPair = new AssetListCriteriaPair();
criteriaPair.setKey(queryEnum.getConfigSearchField());
criteriaPair.setValue(identifier.getVesselIdentifierId());
assetListCriteria.getCriterias().add(criteriaPair);
} else {
log.warn("For Identifier : '" + identifier.getVesselIdentifierSchemeId() + "' it was not found the counterpart in the VesselTypeAssetQueryEnum.");
}
}
// DO not know why
assetListCriteria.setIsDynamic(false);
assetListQuery.setAssetSearchCriteria(assetListCriteria);
// Set asset pagination
AssetListPagination pagination = new AssetListPagination();
pagination.setPage(1);
pagination.setListSize(1000);
assetListQuery.setPagination(pagination);
return assetListQuery;
}
Aggregations