src/main/java/com/ircnet/service/clis/web/controller/ClisRestController.java
/**
     *  Finds channels by given criteria.
     *
     * @return JSON response containing a list of channels and some meta data
     */
Finds channels by given criteria.
@return JSON response containing a list of channels and some meta data
Finds channels by given criteria . @return JSON response containing a list of channels and some meta data
@RequestMapping(value = "/", method = RequestMethod.POST)
    @CrossOrigin(origins = "*")
    public DTResponse postList(@RequestBody DTRequest input) {
      String channelFilter = null;
      String topicFilter = null;
      SortBy sortBy = SortBy.NAME;
      SortOrder sortOrder = SortOrder.ASC;
      try {
        Order order = input.getOrder().get(0);
        Integer orderColumn = order.getColumn();
        if (orderColumn != null) {
          Column column = input.getColumns().get(orderColumn);
          if (column != null) {
            sortBy = SortBy.valueOf(StringUtils.upperCase(column.getData()));
            sortOrder = SortOrder.valueOf(StringUtils.upperCase(input.getOrder().get(0).getDir()));
          }
        }
      }
      catch (Exception e) {
        LOGGER.debug("Could not parse sort attributes", e);
      }
      String searchTerm = null;
      if (input.getSearch() != null && !StringUtils.isBlank(input.getSearch().getValue())) {
        searchTerm = input.getSearch().getValue();
      }
      for (Column column : input.getColumns()) {
        Search search = column.getSearch();
        if (search != null && !StringUtils.isBlank(search.getValue())) {
          if (column.getData().equalsIgnoreCase(FilterBy.NAME.name())) {
            channelFilter = search.getValue();
          }
          else if (column.getData().equalsIgnoreCase(FilterBy.TOPIC.name())) {
            topicFilter = search.getValue();
          }
        }
      }
      Collection<ChannelData> channels = channelService.find(searchTerm, channelFilter, MatchType.CONTAINS, topicFilter, null, null, sortBy, sortOrder);
      List<ChannelData> sublist = new ArrayList<>(channels).subList(input.getStart(), Math.min(input.getStart() + channels.size() - input.getStart(), input.getStart() + input.getLength()));
      List<ChannelDTO> channelDTOs = sublist.stream().map(e -> new ChannelDTO(e)).collect(Collectors.toList());
      return new DTResponse<>(input.getDraw(), channels.size(), channels.size(), channelDTOs);
    }
@ RequestMapping ( value = "/" , method = RequestMethod . POST ) @ CrossOrigin ( origins = "*" ) public DTResponse postList ( @ RequestBody DTRequest input ) { String channelFilter = null ; String topicFilter = null ; SortBy sortBy = SortBy . NAME ; SortOrder sortOrder = SortOrder . ASC ; try { Order order = input . getOrder ( ) . get ( 0 ) ; Integer orderColumn = order . getColumn ( ) ; if ( orderColumn != null ) { Column column = input . getColumns ( ) . get ( orderColumn ) ; if ( column != null ) { sortBy = SortBy . valueOf ( StringUtils . upperCase ( column . getData ( ) ) ) ; sortOrder = SortOrder . valueOf ( StringUtils . upperCase ( input . getOrder ( ) . get ( 0 ) . getDir ( ) ) ) ; } } } catch ( Exception e ) { LOGGER . debug ( "Could not parse sort attributes" , e ) ; } String searchTerm = null ; if ( input . getSearch ( ) != null && ! StringUtils . isBlank ( input . getSearch ( ) . getValue ( ) ) ) { searchTerm = input . getSearch ( ) . getValue ( ) ; } for ( Column column : input . getColumns ( ) ) { Search search = column . getSearch ( ) ; if ( search != null && ! StringUtils . isBlank ( search . getValue ( ) ) ) { if ( column . getData ( ) . equalsIgnoreCase ( FilterBy . NAME . name ( ) ) ) { channelFilter = search . getValue ( ) ; } else if ( column . getData ( ) . equalsIgnoreCase ( FilterBy . TOPIC . name ( ) ) ) { topicFilter = search . getValue ( ) ; } } } Collection < ChannelData > channels = channelService . find ( searchTerm , channelFilter , MatchType . CONTAINS , topicFilter , null , null , sortBy , sortOrder ) ; List < ChannelData > sublist = new ArrayList < > ( channels ) . subList ( input . getStart ( ) , Math . min ( input . getStart ( ) + channels . size ( ) - input . getStart ( ) , input . getStart ( ) + input . getLength ( ) ) ) ; List < ChannelDTO > channelDTOs = sublist . stream ( ) . map ( e -> new ChannelDTO ( e ) ) . collect ( Collectors . toList ( ) ) ; return new DTResponse < > ( input . getDraw ( ) , channels . size ( ) , channels . size ( ) , channelDTOs ) ; }
Finds channels by given criteria.
Finds channels by given criteria .
// global search // column specific search