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