Line | |
---|
1 | package eu.clarin.cmdi.vlo.importer; |
---|
2 | |
---|
3 | import java.util.Arrays; |
---|
4 | import java.util.List; |
---|
5 | import java.util.Map; |
---|
6 | |
---|
7 | public class OrganisationPostProcessor extends PostProcessorsWithVocabularyMap{ |
---|
8 | |
---|
9 | |
---|
10 | private static Map<String, String> organisationNamesMap = null; |
---|
11 | |
---|
12 | /** |
---|
13 | * Splits values for organisation facet at delimiter ';' and replaces |
---|
14 | * organisation name variants with their official name from a controlled |
---|
15 | * vocabulary |
---|
16 | * |
---|
17 | * @param value extracted organisation name/names |
---|
18 | * @return List of organisation names (splitted at semicolon) and variations |
---|
19 | * replaced with controlled vocabulary |
---|
20 | */ |
---|
21 | @Override |
---|
22 | public List<String> process(String value) { |
---|
23 | String[] splitArray = normalizeInputString(value).split(";"); |
---|
24 | for (int i = 0; i < splitArray.length; i++) { |
---|
25 | String normalizedVal = normalize(splitArray[i], null); |
---|
26 | if(normalizedVal != null) |
---|
27 | splitArray[i] = normalizedVal; |
---|
28 | } |
---|
29 | |
---|
30 | return Arrays.asList(splitArray); |
---|
31 | } |
---|
32 | |
---|
33 | @Override |
---|
34 | public String getNormalizationMapURL() { |
---|
35 | return MetadataImporter.config.getOrganisationNamesUrl(); |
---|
36 | } |
---|
37 | |
---|
38 | private String normalizeInputString(String value) { |
---|
39 | return value.replaceAll("\\s+", " "); |
---|
40 | } |
---|
41 | |
---|
42 | private String normalizeVariant(String key) { |
---|
43 | return key.toLowerCase().replaceAll("-", " "); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.