Revision 57661
Added by Michele Artini over 4 years ago
VocabulariesController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.organizations.controller; |
2 | 2 |
|
3 |
import java.util.ArrayList; |
|
3 | 4 |
import java.util.Arrays; |
4 | 5 |
import java.util.HashMap; |
5 | 6 |
import java.util.List; |
... | ... | |
22 | 23 |
@Autowired |
23 | 24 |
private DatabaseUtils databaseUtils; |
24 | 25 |
|
25 |
@GetMapping({ "/api/vocabularies", "/public_api/vocabularies" })
|
|
26 |
@GetMapping("/api/vocabularies")
|
|
26 | 27 |
public Map<String, List<String>> ListVocabularies(final Authentication authentication) { |
27 | 28 |
final Map<String, List<String>> vocs = new HashMap<>(); |
28 | 29 |
vocs.put("orgTypes", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.org_types)); |
... | ... | |
32 | 33 |
vocs.put("relTypes", Arrays.stream(RelationType.values()).map(Object::toString).collect(Collectors.toList())); |
33 | 34 |
vocs.put("similaritiesType", Arrays.stream(SimilarityType.values()).map(Object::toString).collect(Collectors.toList())); |
34 | 35 |
|
35 |
if (UserInfo.isSimpleUser(authentication)) { |
|
36 |
if (UserInfo.isSimpleUser(authentication) || UserInfo.isNationalAdmin(authentication)) {
|
|
36 | 37 |
vocs.put("countries", databaseUtils.listCountriesForUser(authentication.getName())); |
38 |
} else if (UserInfo.isSuperAdmin(authentication)) { |
|
39 |
vocs.put("countries", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.countries)); |
|
37 | 40 |
} else { |
38 |
vocs.put("countries", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.countries));
|
|
41 |
vocs.put("countries", new ArrayList<String>());
|
|
39 | 42 |
} |
40 | 43 |
|
41 | 44 |
return vocs; |
42 | 45 |
} |
43 | 46 |
|
47 |
@GetMapping({ "/api/voc/allCountries", "/registration_api/voc/allCountries" }) |
|
48 |
public List<String> allCountries() { |
|
49 |
return databaseUtils.listValuesOfVocabularyTable(VocabularyTable.countries); |
|
50 |
} |
|
51 |
|
|
44 | 52 |
} |
Also available in: Unified diff
national admin management