ref #10178 namematching Controller
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / NameMatchingController.java
1 /**
2 * Copyright (C) 2024 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.cdm.remote.controller;
10
11 import java.io.IOException;
12
13 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.web.bind.annotation.PathVariable;
15 import org.springframework.web.bind.annotation.RequestMapping;
16 import org.springframework.web.bind.annotation.RequestMethod;
17 import org.springframework.web.bind.annotation.RestController;
18
19 import eu.etaxonomy.cdm.api.service.INameMatchingService;
20 import eu.etaxonomy.cdm.api.service.NameMatchingServiceImpl.NameMatchingResult;
21 import io.swagger.annotations.Api;
22
23 /**
24 * @author andreabee90
25 * @since 05.03.2024
26 */
27
28 @RestController
29 @Api("name_matching")
30 @RequestMapping(value = {"/namecache/{namecache}" })
31
32 public class NameMatchingController {
33
34 @Autowired
35 private INameMatchingService nameMatchingservice;
36
37
38 @RequestMapping(
39 value = {"match"},
40 method = RequestMethod.GET)
41 public NameMatchingResult doGetNameMatching(
42 @PathVariable("namecache") String nameCache) throws IOException {
43 if (nameCache!= null & !nameCache.isEmpty()) {
44 nameCache= nameCache.substring(0,1).toUpperCase() + nameCache.substring(1).toLowerCase();
45 }
46 NameMatchingResult result = nameMatchingservice.findMatchingNames(nameCache, null, false);
47 return result;
48 }
49 }