use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method getFishingActivityForView.
/**
* Gets a FishingActivityEntity with a certain activityId and maps it to a FishingActivityViewDTO representation layer POJO.
*
* @param activityId
* @param datasets
* @return
* @throws ServiceException
*/
@Override
public FishingActivityViewDTO getFishingActivityForView(Integer activityId, String tripId, List<Dataset> datasets, ActivityViewEnum view) throws ServiceException {
Geometry geom = getRestrictedAreaGeometry(datasets);
FishingActivityEntity activityEntity = fishingActivityDao.getFishingActivityById(activityId, geom);
if (activityEntity == null)
throw new ServiceException("Could not find FishingActivityEntity for the given id:" + activityId);
log.debug("FishingActivityEntity fetched from database with id:" + activityEntity.getId());
FishingActivityViewDTO fishingActivityViewDTO = ActivityViewMapperFactory.getMapperForView(view).mapFaEntityToFaDto(activityEntity);
fishingActivityViewDTO.setTripDetails(fishingTripServiceBean.getTripWidgetDto(activityEntity, tripId));
log.debug("fishingActivityView generated after mapping is :" + fishingActivityViewDTO);
addPortDescriptions(fishingActivityViewDTO, "LOCATION");
fishingActivityViewDTO.setTripDetails(fishingTripServiceBean.getTripWidgetDto(activityEntity, tripId));
fishingActivityViewDTO.setHistory(getActivityHistoryDto(activityEntity));
log.debug("fishingActivityView generated after mapping is :" + fishingActivityViewDTO);
return fishingActivityViewDTO;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityDao method getFishingActivityById.
/**
* Returns a FishingActivityEntity with joined tables depending on the view (ARRIVAL, DEPARTURE, etc..).
*
* @param activityId
* @param geom
* @return
*/
public FishingActivityEntity getFishingActivityById(Integer activityId, Geometry geom) {
String s = fillQueryConditions(geom);
Query typedQuery = getEntityManager().createQuery(s);
typedQuery.setParameter("fishingActivityId", activityId);
if (geom != null) {
typedQuery.setParameter("area", geom);
}
List<FishingActivityEntity> resultList = typedQuery.getResultList();
if (CollectionUtils.isEmpty(resultList)) {
return null;
}
return resultList.get(0);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityDataUtil method getFishingActivityEntity.
public static FishingActivityEntity getFishingActivityEntity(String typeCode, String typeCodeListId, Date occurence, String reasonCode, String reasonCodeListId, FaReportDocumentEntity faReportDocumentEntity, FishingActivityEntity relatedfishingActivityEntity) {
FishingActivityEntity fishingActivityEntity = new FishingActivityEntity();
fishingActivityEntity.setTypeCode(typeCode);
fishingActivityEntity.setTypeCodeListid(typeCodeListId);
fishingActivityEntity.setOccurence(occurence);
fishingActivityEntity.setReasonCode(reasonCode);
fishingActivityEntity.setReasonCodeListId(reasonCodeListId);
fishingActivityEntity.setFaReportDocument(faReportDocumentEntity);
fishingActivityEntity.setRelatedFishingActivity(relatedfishingActivityEntity);
return fishingActivityEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getFishingActivityEntityList.
public static List<FishingActivityEntity> getFishingActivityEntityList() {
FishingTripEntity entity = new FishingTripEntity();
FluxReportDocumentEntity fluxReportDocumentEntity1 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT1", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID1", "flux1");
FluxReportDocumentEntity fluxReportDocumentEntity2 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT2", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID2", "flux2");
FluxReportDocumentEntity fluxReportDocumentEntity3 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT3", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID3", "flux3");
VesselTransportMeansEntity vesselTransportMeansEntity1 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup1", null);
VesselTransportMeansEntity vesselTransportMeansEntity2 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup2", null);
VesselTransportMeansEntity vesselTransportMeansEntity3 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup3", null);
FaReportDocumentEntity faReportDocumentEntity1 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity1, vesselTransportMeansEntity1, "new");
FaReportDocumentEntity faReportDocumentEntity2 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity2, vesselTransportMeansEntity2, "new");
FaReportDocumentEntity faReportDocumentEntity3 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity3, vesselTransportMeansEntity3, "new");
FishingActivityEntity fishingActivityEntity1 = ActivityDataUtil.getFishingActivityEntity("DEPARTURE", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity1, null);
FishingActivityEntity fishingActivityEntity2 = ActivityDataUtil.getFishingActivityEntity("ARRIVAL", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity2, null);
FishingActivityEntity fishingActivityEntity3 = ActivityDataUtil.getFishingActivityEntity("LANDING", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity3, null);
List<FishingActivityEntity> fishingActivityEntityList = new ArrayList<>();
fishingActivityEntityList.add(fishingActivityEntity1);
fishingActivityEntityList.add(fishingActivityEntity2);
fishingActivityEntityList.add(fishingActivityEntity3);
return fishingActivityEntityList;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity 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