Project

General

Profile

1
package eu.dnetlib.organizations.controller;
2

    
3
import java.util.Arrays;
4
import java.util.HashMap;
5
import java.util.List;
6
import java.util.Map;
7
import java.util.stream.Collectors;
8

    
9
import org.springframework.beans.factory.annotation.Autowired;
10
import org.springframework.web.bind.annotation.RequestMapping;
11
import org.springframework.web.bind.annotation.RequestMethod;
12
import org.springframework.web.bind.annotation.RestController;
13

    
14
import eu.dnetlib.organizations.utils.DatabaseUtils;
15
import eu.dnetlib.organizations.utils.DatabaseUtils.VocabularyTable;
16
import eu.dnetlib.organizations.utils.RelationType;
17
import eu.dnetlib.organizations.utils.SimilarityType;
18

    
19
@RestController
20
@RequestMapping("/api/vocabularies")
21
public class VocabulariesController {
22

    
23
	@Autowired
24
	private DatabaseUtils databaseUtils;
25

    
26
	@RequestMapping(value = "", method = RequestMethod.GET)
27
	public Map<String, List<String>> ListVocabularies() {
28
		final Map<String, List<String>> vocs = new HashMap<>();
29
		vocs.put("orgTypes", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.org_types));
30
		vocs.put("idTypes", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.id_types));
31
		vocs.put("languages", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.languages));
32
		vocs.put("countries", databaseUtils.listValuesOfVocabularyTable(VocabularyTable.countries));
33
		vocs.put("relTypes", Arrays.stream(RelationType.values()).map(Object::toString).collect(Collectors.toList()));
34
		vocs.put("similaritiesType", Arrays.stream(SimilarityType.values()).map(Object::toString).collect(Collectors.toList()));
35
		return vocs;
36
	}
37

    
38
}
(3-3/3)