1 | package eu.clarin.cmdi.vlo.pojo; |
---|
2 | |
---|
3 | import java.util.LinkedList; |
---|
4 | import java.util.List; |
---|
5 | import java.util.Map; |
---|
6 | import java.util.TreeMap; |
---|
7 | |
---|
8 | import javax.xml.bind.annotation.XmlAccessType; |
---|
9 | import javax.xml.bind.annotation.XmlAccessorType; |
---|
10 | import javax.xml.bind.annotation.XmlAttribute; |
---|
11 | import javax.xml.bind.annotation.XmlElement; |
---|
12 | import javax.xml.bind.annotation.XmlRootElement; |
---|
13 | |
---|
14 | /** |
---|
15 | * @author dostojic |
---|
16 | * |
---|
17 | */ |
---|
18 | |
---|
19 | |
---|
20 | @XmlAccessorType(XmlAccessType.FIELD) |
---|
21 | @XmlRootElement(name = "mappings") |
---|
22 | public class VariantsMap{ |
---|
23 | |
---|
24 | @XmlAttribute |
---|
25 | private String field; |
---|
26 | |
---|
27 | @XmlElement(name = "mapping") |
---|
28 | private List<Mapping> mappings; |
---|
29 | |
---|
30 | public List<Mapping> getMappings() { |
---|
31 | return mappings; |
---|
32 | } |
---|
33 | |
---|
34 | public void setMappings(List<Mapping> mappings) { |
---|
35 | this.mappings = mappings; |
---|
36 | } |
---|
37 | |
---|
38 | public String getField() { |
---|
39 | return field; |
---|
40 | } |
---|
41 | |
---|
42 | public void setField(String field) { |
---|
43 | this.field = field; |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | /** |
---|
48 | * returns inverted map variant-normalizedVal |
---|
49 | * |
---|
50 | */ |
---|
51 | |
---|
52 | public Map<String, String> getInvertedMap(){ |
---|
53 | Map<String, String> invMap = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER); |
---|
54 | for(Mapping m: mappings){ |
---|
55 | if(m.getVariants() != null) |
---|
56 | for(Variant variant: m.getVariants()) |
---|
57 | if(!variant.isRegExp()) |
---|
58 | invMap.put(variant.getValue(), m.getValue()); |
---|
59 | } |
---|
60 | |
---|
61 | return invMap; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | public List<VocabularyEntry> getMap(){ |
---|
66 | List map = new LinkedList<VocabularyEntry>(); |
---|
67 | |
---|
68 | for(Mapping m: mappings) |
---|
69 | if(m.getVariants() != null) |
---|
70 | for(Variant v: m.getVariants()){ |
---|
71 | map.add(new VocabularyEntry(v.getValue(), m.getValue(), v.isRegExp(), v.getCrossMappings())); |
---|
72 | } |
---|
73 | |
---|
74 | return map; |
---|
75 | |
---|
76 | } |
---|
77 | |
---|
78 | } |
---|