Search in sources :

Example 1 with SearchDto

use of com.icthh.xm.ms.entity.service.dto.SearchDto in project xm-ms-entity by xm-online.

the class XmEntityResource method searchXmEntitiesV2.

@GetMapping("/_search/v2/xm-entities")
@Timed
@PreAuthorize("hasPermission({'query': #query}, 'XMENTITY.SEARCH.QUERY')")
@PrivilegeDescription("Privilege to search for the xmEntity corresponding to the query")
public ResponseEntity<List<XmEntity>> searchXmEntitiesV2(@RequestParam String query, @ApiParam Pageable pageable, @ApiParam ElasticFetchSourceFilterDto fetchSourceFilterDto) {
    SearchDto searchDto = SearchDto.builder().query(query).pageable(pageable).entityClass(XmEntity.class).fetchSourceFilter(new FetchSourceFilter(fetchSourceFilterDto.getIncludes(), fetchSourceFilterDto.getExcludes())).build();
    Page<XmEntity> page = xmEntityService.searchV2(searchDto, null);
    HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/xm-entities");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) FetchSourceFilter(org.springframework.data.elasticsearch.core.query.FetchSourceFilter) SearchDto(com.icthh.xm.ms.entity.service.dto.SearchDto) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) GetMapping(org.springframework.web.bind.annotation.GetMapping) Timed(com.codahale.metrics.annotation.Timed) PrivilegeDescription(com.icthh.xm.commons.permission.annotation.PrivilegeDescription) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Timed (com.codahale.metrics.annotation.Timed)1 PrivilegeDescription (com.icthh.xm.commons.permission.annotation.PrivilegeDescription)1 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)1 SearchDto (com.icthh.xm.ms.entity.service.dto.SearchDto)1 FetchSourceFilter (org.springframework.data.elasticsearch.core.query.FetchSourceFilter)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1