Revision 57650
Added by Michele Artini over 4 years ago
VocabulariesController.java | ||
---|---|---|
8 | 8 |
|
9 | 9 |
import org.springframework.beans.factory.annotation.Autowired; |
10 | 10 |
import org.springframework.security.core.Authentication; |
11 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
12 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
11 |
import org.springframework.web.bind.annotation.GetMapping; |
|
13 | 12 |
import org.springframework.web.bind.annotation.RestController; |
14 | 13 |
|
15 | 14 |
import eu.dnetlib.organizations.utils.DatabaseUtils; |
... | ... | |
18 | 17 |
import eu.dnetlib.organizations.utils.SimilarityType; |
19 | 18 |
|
20 | 19 |
@RestController |
21 |
@RequestMapping("/api/vocabularies") |
|
22 | 20 |
public class VocabulariesController { |
23 | 21 |
|
24 | 22 |
@Autowired |
25 | 23 |
private DatabaseUtils databaseUtils; |
26 | 24 |
|
27 |
@RequestMapping(value = "", method = RequestMethod.GET)
|
|
25 |
@GetMapping({ "/api/vocabularies", "/public_api/vocabularies" })
|
|
28 | 26 |
public Map<String, List<String>> ListVocabularies(final Authentication authentication) { |
29 | 27 |
final Map<String, List<String>> vocs = new HashMap<>(); |
30 | 28 |
vocs.put("orgTypes", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.org_types)); |
... | ... | |
34 | 32 |
vocs.put("relTypes", Arrays.stream(RelationType.values()).map(Object::toString).collect(Collectors.toList())); |
35 | 33 |
vocs.put("similaritiesType", Arrays.stream(SimilarityType.values()).map(Object::toString).collect(Collectors.toList())); |
36 | 34 |
|
37 |
if (UserInfo.isSuperUser(authentication)) { |
|
35 |
if (UserInfo.isSimpleUser(authentication)) { |
|
36 |
vocs.put("countries", databaseUtils.listCountriesForUser(authentication.getName())); |
|
37 |
} else { |
|
38 | 38 |
vocs.put("countries", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.countries)); |
39 |
} else { |
|
40 |
vocs.put("countries", databaseUtils.listCountriesForUser(authentication.getName())); |
|
41 | 39 |
} |
42 | 40 |
|
43 | 41 |
return vocs; |
Also available in: Unified diff
new registration form