Commit 343ef00c authored by Kristjan Kruus's avatar Kristjan Kruus

Merge pull request #33 in RIHA/riha-browser from...

Merge pull request #33 in RIHA/riha-browser from bugfix/RIHAKB-823-riha-kasutajana-soovin-et-seoste-lisamisel-toimiks-autocomplete-i-sortimine to develop

* commit '972d965a':
  bugfixing
parents 9e97f3b4 972d965a
......@@ -14,6 +14,7 @@ import ee.ria.riha.web.model.RelationModel;
import ee.ria.riha.web.model.StandardRealisationCreationModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
......@@ -62,9 +63,16 @@ public class InfoSystemController {
@ApiOperation("List all existing information systems for autocomplete")
public ResponseEntity autocomplete(@RequestParam("searchTerm") String searchTerm) {
String paramToRestEndpoint;
if (StringUtils.isNumeric(searchTerm)) {
paramToRestEndpoint = "'" + searchTerm + "'";
} else {
paramToRestEndpoint = searchTerm;
}
PageRequest pageable = new PageRequest(0, 10);
FilterRequest shortNameExact = new FilterRequest("short_name,ilike,'" + searchTerm + "'", "desc", "id");
FilterRequest nameExact = new FilterRequest("name,ilike,'" + searchTerm+"'", "desc", "id");
FilterRequest shortNameExact = new FilterRequest("short_name,ilike," + paramToRestEndpoint, "desc", "id");
FilterRequest nameExact = new FilterRequest("name,ilike," + paramToRestEndpoint, "desc", "id");
FilterRequest nameFuzzy = new FilterRequest("name,ilike,%" + searchTerm + "%", "desc", "id");
List<InfoSystem> foundResults = new ArrayList<>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment