use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method setTripStartAndEndDateForFishingTrip.
private void setTripStartAndEndDateForFishingTrip(FishingTripEntity fishingTripEntity) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
if (CollectionUtils.isEmpty(identifierEntities))
return;
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
try {
List<FishingActivityEntity> fishingActivityEntityList = fishingTripService.getAllFishingActivitiesForTrip(tripIdentifierEntity.getTripId());
if (CollectionUtils.isNotEmpty(fishingActivityEntityList)) {
// Calculate trip start date
FishingActivityEntity firstFishingActivity = fishingActivityEntityList.get(0);
tripIdentifierEntity.setCalculatedTripStartDate(firstFishingActivity.getCalculatedStartTime());
// calculate trip end date
Date calculatedTripEndDate;
int totalActivities = fishingActivityEntityList.size();
if (totalActivities > 1) {
calculatedTripEndDate = fishingActivityEntityList.get(totalActivities - 1).getCalculatedStartTime();
} else {
calculatedTripEndDate = firstFishingActivity.getCalculatedStartTime();
}
tripIdentifierEntity.setCalculatedTripEndDate(calculatedTripEndDate);
}
} catch (Exception e) {
log.error("Error while trying to calculate FishingTrip start and end Date", e);
}
}
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method addToIdsList.
private void addToIdsList(List<FaIdsListWithTripIdMap> responseList, FishingActivityEntity faEntity) {
Set<FishingTripIdentifierEntity> fishingTripIdentifiers = faEntity.getFishingTrips().iterator().next().getFishingTripIdentifiers();
List<FishingActivityWithIdentifiers> faIdentifiers = mapToActivityIdsAndType(faEntity.getFishingActivityIdentifiers(), faEntity.getTypeCode());
for (FishingTripIdentifierEntity tripIdentifEntity : fishingTripIdentifiers) {
FaIdsListWithTripIdMap existingActWithIdentifiers = getElementWithTripId(responseList, tripIdentifEntity.getTripId());
if (null != existingActWithIdentifiers) {
existingActWithIdentifiers.getFaIdentifierLists().addAll(faIdentifiers);
} else {
responseList.add(new FaIdsListWithTripIdMap(tripIdentifEntity.getTripId(), tripIdentifEntity.getTripSchemeId(), faIdentifiers));
}
}
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripIdentifierDao method getCurrentTrip.
public FishingTripIdentifierEntity getCurrentTrip(String vesselId, String vesselSchemeId) {
TypedQuery query = getEntityManager().createNamedQuery(FishingTripIdentifierEntity.FIND_CURRENT_TRIP, FishingTripIdentifierEntity.class);
query.setParameter(VESSEL_ID, vesselId);
query.setParameter(VESSEL_SCHEME_ID, vesselSchemeId);
query.setMaxResults(1);
List<FishingTripIdentifierEntity> fishingTripIdentifies = query.getResultList();
if (CollectionUtils.isNotEmpty(fishingTripIdentifies)) {
return fishingTripIdentifies.get(0);
} else {
return null;
}
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityDataUtil method getFishingTripIdentifierEntity.
public static FishingTripIdentifierEntity getFishingTripIdentifierEntity(FishingTripEntity fishingTripEntity, String tripId, String tripSchemeId) {
FishingTripIdentifierEntity fishingTripIdentifierEntity = new FishingTripIdentifierEntity();
fishingTripIdentifierEntity.setFishingTrip(fishingTripEntity);
fishingTripIdentifierEntity.setTripId(tripId);
fishingTripIdentifierEntity.setTripSchemeId(tripSchemeId);
try {
fishingTripIdentifierEntity.setCalculatedTripEndDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/01/2016"));
fishingTripIdentifierEntity.setCalculatedTripStartDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/01/2013"));
} catch (ParseException e) {
e.printStackTrace();
}
return fishingTripIdentifierEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBeanTest method mockFishActEntities.
private List<FishingActivityEntity> mockFishActEntities() {
final FishingActivityEntity fishAct = new FishingActivityEntity();
FishingActivityIdentifierEntity ident = new FishingActivityIdentifierEntity();
ident.setFaIdentifierId("faId");
ident.setFaIdentifierSchemeId("faSchemeId");
Set<FishingActivityIdentifierEntity> fishIdentList = new HashSet<>();
fishIdentList.add(ident);
Set<FishingTripEntity> fishTrips = new HashSet<>();
FishingTripEntity fishTrip = new FishingTripEntity();
Set<FishingTripIdentifierEntity> fishingTripIdentifiers = new HashSet<>();
FishingTripIdentifierEntity tripident = new FishingTripIdentifierEntity();
tripident.setTripId("tripId");
tripident.setTripSchemeId("tripSchemeId");
fishingTripIdentifiers.add(tripident);
fishTrips.add(fishTrip);
fishTrip.setTypeCode("someTripCode");
fishTrip.setFishingActivity(fishAct);
fishTrip.setFishingTripIdentifiers(fishingTripIdentifiers);
fishAct.setFishingActivityIdentifiers(fishIdentList);
fishAct.setTypeCode("faTypeCode");
fishAct.setFishingTrips(fishTrips);
return new ArrayList<FishingActivityEntity>() {
{
add(fishAct);
}
};
}
Aggregations