Search in sources :

Example 11 with FishingActivityQuery

use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityDao method getFishingActivityListByQuery.

/*
     Get all the Fishing Activities which match Filter criterias mentioned in the Input. Also, provide the sorted data based on what user has requested.
     Provide paginated data if user has asked for it
     */
public List<FishingActivityEntity> getFishingActivityListByQuery(FishingActivityQuery query) throws ServiceException {
    LOG.info("Get Fishing Activity Report list by Query.");
    FishingActivitySearchBuilder search = new FishingActivitySearchBuilder();
    // Create Query dynamically based on filter and Sort criteria
    StringBuilder sqlToGetActivityList = search.createSQL(query);
    // Apply real values to Query built
    Query listQuery = getTypedQueryForFishingActivityFilter(sqlToGetActivityList, query, search);
    // Agreed with frontend.
    // Page size : Number of record to be retrieved in one page
    // offSet : The position from where the result should be picked. Starts with 0
    PaginationDto pagination = query.getPagination();
    if (pagination != null) {
        LOG.debug("Pagination information getting applied to Query is: Offset :" + pagination.getOffset() + " PageSize:" + pagination.getPageSize());
        listQuery.setFirstResult(pagination.getOffset());
        listQuery.setMaxResults(pagination.getPageSize());
    }
    return listQuery.getResultList();
}
Also used : FishingActivitySearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder) Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto)

Example 12 with FishingActivityQuery

use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityDao method getTypedQueryForFishingActivityFilter.

/**
 * Set typed values for Dynamically generated Query
 */
private Query getTypedQueryForFishingActivityFilter(StringBuilder sql, FishingActivityQuery query, FishingActivitySearchBuilder search) throws ServiceException {
    LOG.debug("Set Typed Parameters to Query");
    Query typedQuery = em.createQuery(sql.toString());
    return search.fillInValuesForTypedQuery(query, typedQuery);
}
Also used : Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)

Example 13 with FishingActivityQuery

use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityDao method getCountForFishingActivityListByQuery.

public Integer getCountForFishingActivityListByQuery(FishingActivityQuery query) throws ServiceException {
    FishingActivitySearchBuilder search = new FishingActivitySearchBuilder();
    LOG.info("Get Total Count for Fishing Activities When filter criteria is present");
    StringBuilder sqlToGetActivityListCount = search.createSQL(query);
    Query countQuery = getTypedQueryForFishingActivityFilter(sqlToGetActivityListCount, query, search);
    return countQuery.getResultList().size();
}
Also used : FishingActivitySearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder) Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)

Example 14 with FishingActivityQuery

use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripDao method getFishingTripsForMatchingFilterCriteria.

/**
 * Get all the Fishing Trip entities for matching Filters
 *
 * @param query FishingActivityQuery
 * @return
 * @throws ServiceException
 */
public List<FishingTripEntity> getFishingTripsForMatchingFilterCriteria(FishingActivityQuery query) throws ServiceException {
    Query listQuery = getQueryForFilterFishingTrips(query);
    PaginationDto pagination = query.getPagination();
    if (pagination != null) {
        log.debug("Pagination information getting applied to Query is: Offset :" + pagination.getOffset() + " PageSize:" + pagination.getPageSize());
        listQuery.setFirstResult(pagination.getOffset());
        listQuery.setMaxResults(pagination.getPageSize());
    }
    return listQuery.getResultList();
}
Also used : TypedQuery(javax.persistence.TypedQuery) Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto)

Example 15 with FishingActivityQuery

use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchReportServiceBean method getCatchDetailsScreenTable.

/**
 * This method gets you table structure for Catch details summary on TRIP SUMMARY VIEW
 * @param tripId data will be returned for this tripId
 * @param isLanding If landing then summary structure will include PRESENTATION information otherwise only species information will be included
 * @return
 * @throws ServiceException
 */
public FACatchSummaryDTO getCatchDetailsScreenTable(String tripId, boolean isLanding) throws ServiceException {
    FishingActivityQuery query = new FishingActivityQuery();
    List<GroupCriteria> groupByFields = getGroupByFields(isLanding);
    query.setGroupByFields(groupByFields);
    Map<SearchFilter, String> searchCriteriaMap = new EnumMap<>(SearchFilter.class);
    searchCriteriaMap.put(SearchFilter.TRIP_ID, tripId);
    query.setSearchCriteriaMap(searchCriteriaMap);
    return getCatchSummaryReport(query, isLanding);
}
Also used : FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) EnumMap(java.util.EnumMap) GroupCriteria(eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)

Aggregations

FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)28 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)19 Test (org.junit.Test)17 SneakyThrows (lombok.SneakyThrows)16 ArrayList (java.util.ArrayList)15 HashMap (java.util.HashMap)14 List (java.util.List)14 PaginationDto (eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto)10 Query (javax.persistence.Query)7 SortKey (eu.europa.ec.fisheries.ers.service.search.SortKey)6 FishingTripId (eu.europa.ec.fisheries.ers.service.search.FishingTripId)5 EnumMap (java.util.EnumMap)5 FishingActivitySearchBuilder (eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder)4 GroupCriteria (eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)4 TypedQuery (javax.persistence.TypedQuery)4 FishingTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse)3 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 FilterFishingActivityReportResultDTO (eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO)2 SearchQueryBuilder (eu.europa.ec.fisheries.ers.service.search.builder.SearchQueryBuilder)2