use of au.org.ala.spatial.composer.results.PhylogeneticDiversityListResults in project spatial-portal by AtlasOfLivingAustralia.
the class PhylogeneticDiversityComposer method onFinish.
@Override
public boolean onFinish() {
List<SelectedArea> sa = getSelectedAreas();
if (autoCompleteLayerSelection != null && cAreasFromLayer.isChecked()) {
String fieldId = CommonData.getLayerFacetNameDefault(autoCompleteLayerSelection);
String layer = CommonData.getFacetLayerName(fieldId);
JSONObject field = CommonData.getLayer(layer);
JSONObject lyr = (JSONObject) field.get("layer");
String name = field.get(StringConstants.ID).toString();
String uid = lyr.get(StringConstants.ID).toString();
String type = lyr.get(StringConstants.TYPE).toString();
String treeName = StringUtils.capitalize(field.get(StringConstants.NAME).toString());
String treePath = lyr.get("displaypath").toString();
String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=9&LAYER=" + name + "&styles=" + name + "_style";
String metadata = CommonData.getLayersServer() + "/layers/view/more/" + uid;
//is it already mapped with the same display name?
boolean found = false;
for (MapLayer ml : getMapComposer().getContextualLayers()) {
if (ml.getDisplayName().equalsIgnoreCase(treeName)) {
found = true;
break;
}
}
if (!found) {
getMapComposer().addWMSLayer(name, treeName, treePath, (float) 0.75, metadata, legendurl, StringConstants.ENVIRONMENTAL.equalsIgnoreCase(type) ? LayerUtilitiesImpl.GRID : LayerUtilitiesImpl.CONTEXTUAL, null, null, null);
remoteLogger.logMapArea(treeName, "Layer - " + type, treePath, name, metadata);
}
}
Map<String, Object> hm = new HashMap<String, Object>();
hm.put("selectedareas", sa);
List<Object> st = new ArrayList<Object>();
StringBuilder sb = new StringBuilder();
for (Object o : treesList.getSelectedItems()) {
st.add(trees[((Listitem) o).getIndex()]);
if (sb.length() > 0)
sb.append(",");
sb.append(((Map<String, String>) trees[((Listitem) o).getIndex()]).get(StringConstants.STUDY_ID));
}
hm.put("selectedtrees", st);
Query q = getSelectedSpecies();
if (q != null)
q = q.newFacet(new Facet("occurrence_status_s", "absent", false), false);
hm.put("query", q);
PhylogeneticDiversityListResults window = (PhylogeneticDiversityListResults) Executions.createComponents("WEB-INF/zul/results/PhylogeneticDiversityResults.zul", getMapComposer(), hm);
try {
window.setParent(getMapComposer());
window.doModal();
} catch (Exception e) {
LOGGER.error("error opening PhylogeneticDiversityResults.zul", e);
}
remoteLogger.logMapAnalysis("PhylogeneticDiversity", "PhylogeneticDiversity", sa.size() + " areas", getSelectedSpeciesName(), sb.toString(), "", "", "");
detach();
return true;
}
Aggregations