1 |
56340
|
michele.ar
|
package eu.dnetlib.organizations.controller;
|
2 |
|
|
|
3 |
56360
|
michele.ar
|
import java.util.List;
|
4 |
|
|
|
5 |
56340
|
michele.ar
|
import org.springframework.beans.factory.annotation.Autowired;
|
6 |
56360
|
michele.ar
|
import org.springframework.data.domain.Page;
|
7 |
|
|
import org.springframework.data.domain.PageRequest;
|
8 |
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
9 |
56340
|
michele.ar
|
import org.springframework.web.bind.annotation.RequestMapping;
|
10 |
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
11 |
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
12 |
|
|
import org.springframework.web.bind.annotation.RestController;
|
13 |
|
|
|
14 |
56360
|
michele.ar
|
import eu.dnetlib.organizations.model.BrowseEntry;
|
15 |
|
|
import eu.dnetlib.organizations.model.OrganizationSimpleView;
|
16 |
56340
|
michele.ar
|
import eu.dnetlib.organizations.model.OrganizationView;
|
17 |
56511
|
michele.ar
|
import eu.dnetlib.organizations.model.RelationByOrg;
|
18 |
56360
|
michele.ar
|
import eu.dnetlib.organizations.repository.readonly.OrganizationSimpleViewRepository;
|
19 |
56340
|
michele.ar
|
import eu.dnetlib.organizations.repository.readonly.OrganizationViewRepository;
|
20 |
|
|
|
21 |
|
|
@RestController
|
22 |
|
|
@RequestMapping("/api/organizations")
|
23 |
|
|
public class OrganizationController {
|
24 |
|
|
|
25 |
|
|
@Autowired
|
26 |
|
|
private OrganizationViewRepository organizationViewRepository;
|
27 |
56360
|
michele.ar
|
@Autowired
|
28 |
|
|
private OrganizationSimpleViewRepository organizationSimpleViewRepository;
|
29 |
56340
|
michele.ar
|
|
30 |
56360
|
michele.ar
|
@RequestMapping(value = "/get", method = RequestMethod.GET)
|
31 |
56340
|
michele.ar
|
public OrganizationView findById(@RequestParam final String id) {
|
32 |
|
|
return organizationViewRepository.findById(id).get();
|
33 |
|
|
}
|
34 |
|
|
|
35 |
56511
|
michele.ar
|
@RequestMapping(value = "/relations", method = RequestMethod.GET)
|
36 |
|
|
public List<RelationByOrg> findRelationsById(@RequestParam final String id) {
|
37 |
|
|
return organizationSimpleViewRepository.findRelations(id);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
56472
|
michele.ar
|
@RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.GET)
|
41 |
|
|
public Page<OrganizationSimpleView> search(@PathVariable final int page, @PathVariable final int size, @RequestParam final String q) {
|
42 |
|
|
return organizationSimpleViewRepository.findByNameContainingIgnoreCase(q, PageRequest.of(page, size));
|
43 |
|
|
}
|
44 |
|
|
|
45 |
56382
|
michele.ar
|
@RequestMapping(value = "/byCountry/{code}/{page}/{size}", method = RequestMethod.GET)
|
46 |
56360
|
michele.ar
|
public Page<OrganizationSimpleView> findByCountry(@PathVariable final String code, @PathVariable final int page, @PathVariable final int size) {
|
47 |
|
|
return organizationSimpleViewRepository.findByCountry(code, PageRequest.of(page, size));
|
48 |
|
|
}
|
49 |
|
|
|
50 |
56472
|
michele.ar
|
@RequestMapping(value = "/byType/{type}/{page}/{size}", method = RequestMethod.GET)
|
51 |
|
|
public Page<OrganizationSimpleView> findByType(@PathVariable final String type, @PathVariable final int page, @PathVariable final int size) {
|
52 |
|
|
return organizationSimpleViewRepository.findByType(type, PageRequest.of(page, size));
|
53 |
|
|
}
|
54 |
|
|
|
55 |
56360
|
michele.ar
|
@RequestMapping(value = "/browse/countries", method = RequestMethod.GET)
|
56 |
|
|
public List<BrowseEntry> browseCountries() {
|
57 |
|
|
return organizationSimpleViewRepository.browseCountries();
|
58 |
|
|
}
|
59 |
56472
|
michele.ar
|
|
60 |
|
|
@RequestMapping(value = "/browse/types", method = RequestMethod.GET)
|
61 |
|
|
public List<BrowseEntry> browseOrganizationTypes() {
|
62 |
|
|
return organizationSimpleViewRepository.browseTypes();
|
63 |
|
|
}
|
64 |
56340
|
michele.ar
|
}
|