use of eu.etaxonomy.cdm.ext.geo.GeoServiceArea in project cdmlib by cybertaxonomy.
the class MarkupImportBase method makeArea.
/**
* @param state
* @param areaName
* @param level
* @return
*/
protected NamedArea makeArea(MarkupImportState state, String areaName, NamedAreaLevel level) {
// TODO FM vocabulary
TermVocabulary<NamedArea> voc = null;
NamedAreaType areaType = null;
NamedArea area = null;
try {
area = state.getTransformer().getNamedAreaByKey(areaName);
} catch (UndefinedTransformerMethodException e) {
throw new RuntimeException(e);
}
if (area == null) {
boolean isNewInState = false;
UUID uuid = state.getAreaUuid(areaName);
if (uuid == null) {
isNewInState = true;
try {
uuid = state.getTransformer().getNamedAreaUuid(areaName);
if (uuid == null) {
uuid = UUID.randomUUID();
state.putAreaUuid(areaName, uuid);
}
} catch (UndefinedTransformerMethodException e) {
throw new RuntimeException(e);
}
}
CdmImportBase.TermMatchMode matchMode = CdmImportBase.TermMatchMode.UUID_LABEL;
area = getNamedArea(state, uuid, areaName, areaName, areaName, areaType, level, voc, matchMode);
if (isNewInState) {
state.putAreaUuid(areaName, area.getUuid());
// TODO just for testing -> make generic and move to better place
String geoServiceLayer = "vmap0_as_bnd_political_boundary_a";
String layerFieldName = "nam";
if ("Bangka".equals(areaName)) {
String areaValue = "PULAU BANGKA#SUMATERA SELATAN";
GeoServiceArea geoServiceArea = new GeoServiceArea();
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
this.editGeoService.setMapping(area, geoServiceArea);
// save(area, state);
}
if ("Luzon".equals(areaName)) {
GeoServiceArea geoServiceArea = new GeoServiceArea();
List<String> list = Arrays.asList("HERMANA MAYOR ISLAND#CENTRAL LUZON", "HERMANA MENOR ISLAND#CENTRAL LUZON", "CENTRAL LUZON");
for (String areaValue : list) {
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
}
this.editGeoService.setMapping(area, geoServiceArea);
// save(area, state);
}
if ("Mindanao".equals(areaName)) {
GeoServiceArea geoServiceArea = new GeoServiceArea();
List<String> list = Arrays.asList("NORTHERN MINDANAO", "SOUTHERN MINDANAO", "WESTERN MINDANAO");
// TODO to be continued
for (String areaValue : list) {
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
}
this.editGeoService.setMapping(area, geoServiceArea);
// save(area, state);
}
if ("Palawan".equals(areaName)) {
GeoServiceArea geoServiceArea = new GeoServiceArea();
List<String> list = Arrays.asList("PALAWAN#SOUTHERN TAGALOG");
for (String areaValue : list) {
geoServiceArea.add(geoServiceLayer, layerFieldName, areaValue);
}
this.editGeoService.setMapping(area, geoServiceArea);
// save(area, state);
}
}
}
return area;
}
Aggregations