13 |
13 |
import java.io.IOException;
|
14 |
14 |
import java.io.InputStream;
|
15 |
15 |
import java.io.StringWriter;
|
|
16 |
import java.net.URL;
|
16 |
17 |
import java.util.ArrayList;
|
17 |
18 |
import java.util.HashMap;
|
18 |
19 |
import java.util.List;
|
... | ... | |
28 |
29 |
import org.jdom.JDOMException;
|
29 |
30 |
import org.jdom.Namespace;
|
30 |
31 |
|
31 |
|
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
32 |
32 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
33 |
33 |
import eu.etaxonomy.cdm.common.XmlHelp;
|
34 |
|
import eu.etaxonomy.cdm.model.common.Annotation;
|
35 |
|
import eu.etaxonomy.cdm.model.common.AnnotationType;
|
36 |
|
import eu.etaxonomy.cdm.model.common.Language;
|
37 |
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
38 |
34 |
|
39 |
35 |
/**
|
40 |
36 |
* Holds all values to map an NamedArea to a geo service area
|
... | ... | |
54 |
50 |
private static final String MAP_SERVICE = "mapService";
|
55 |
51 |
|
56 |
52 |
|
57 |
|
TreeSet<SubArea> subAreas = new TreeSet<SubArea>();
|
|
53 |
public enum GeoServiceType{
|
|
54 |
EDIT("Edit Geo Service"),
|
|
55 |
WMS("WMS Service");
|
|
56 |
|
|
57 |
private String label;
|
|
58 |
|
|
59 |
private GeoServiceType(String label){
|
|
60 |
this.label = label;
|
|
61 |
}
|
|
62 |
|
|
63 |
public String getLabel(){
|
|
64 |
return label;
|
|
65 |
}
|
|
66 |
}
|
|
67 |
|
|
68 |
private TreeSet<SubArea> subAreas = new TreeSet<SubArea>();
|
|
69 |
private URL serviceUri;
|
|
70 |
private GeoServiceType type;
|
|
71 |
|
58 |
72 |
|
59 |
|
private class SubArea implements Comparable<SubArea>{
|
|
73 |
public class SubArea implements Comparable<SubArea>{
|
60 |
74 |
private String layer;
|
61 |
75 |
private String field;
|
62 |
76 |
private String value;
|
|
77 |
|
63 |
78 |
/* (non-Javadoc)
|
64 |
79 |
* @see java.lang.Object#hashCode()
|
65 |
80 |
*/
|
... | ... | |
83 |
98 |
SubArea subArea = (SubArea)otherArea;
|
84 |
99 |
if (CdmUtils.nullSafeEqual(layer, subArea.layer)
|
85 |
100 |
&& CdmUtils.nullSafeEqual(field, subArea.field)
|
86 |
|
&& CdmUtils.nullSafeEqual(value, subArea.value)){
|
|
101 |
&& CdmUtils.nullSafeEqual(value, subArea.value)
|
|
102 |
){
|
87 |
103 |
return true;
|
88 |
104 |
}else{
|
89 |
105 |
return false;
|
... | ... | |
119 |
135 |
* Returns the areas as a layer, field, area nested map.
|
120 |
136 |
* @return
|
121 |
137 |
*/
|
122 |
|
public Map<String, Map<String, List<String>>> getAreas(){
|
|
138 |
public Map<String, Map<String, List<String>>> getAreasMap(){
|
123 |
139 |
Map<String, Map<String, List<String>>> result = new HashMap<String, Map<String,List<String>>>();
|
124 |
140 |
|
125 |
141 |
for (SubArea area : subAreas){
|
... | ... | |
144 |
160 |
return result;
|
145 |
161 |
}
|
146 |
162 |
|
|
163 |
public List<SubArea> getAreasList(){
|
|
164 |
List<SubArea> result = new ArrayList<SubArea>();
|
|
165 |
for (SubArea area : subAreas){
|
|
166 |
result.add(area);
|
|
167 |
}
|
|
168 |
return result;
|
|
169 |
}
|
|
170 |
|
147 |
171 |
|
148 |
172 |
public static boolean isAreaMapping(String xml){
|
149 |
173 |
//TODO check by parsing or only testing root + namespace
|
... | ... | |
229 |
253 |
}
|
230 |
254 |
|
231 |
255 |
private void writeAreas(XMLStreamWriter writer) throws XMLStreamException {
|
232 |
|
Map<String, Map<String, List<String>>> areaMap = getAreas();
|
|
256 |
Map<String, Map<String, List<String>>> areaMap = getAreasMap();
|
233 |
257 |
//TODO multiple
|
234 |
258 |
for (String layerKey : areaMap.keySet()){
|
235 |
259 |
Map<String, List<String>> layer = areaMap.get(layerKey);
|
some changes in GeoServiceArea