Search in sources :

Example 1 with PhylogeneticDiversityListResults

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;
}
Also used : Query(au.org.ala.spatial.util.Query) PhylogeneticDiversityListResults(au.org.ala.spatial.composer.results.PhylogeneticDiversityListResults) HashMap(java.util.HashMap) SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) ArrayList(java.util.ArrayList) ParseException(org.json.simple.parser.ParseException) JSONObject(org.json.simple.JSONObject) JSONObject(org.json.simple.JSONObject) Facet(au.org.ala.legend.Facet)

Aggregations

Facet (au.org.ala.legend.Facet)1 PhylogeneticDiversityListResults (au.org.ala.spatial.composer.results.PhylogeneticDiversityListResults)1 Query (au.org.ala.spatial.util.Query)1 MapLayer (au.org.emii.portal.menu.MapLayer)1 SelectedArea (au.org.emii.portal.menu.SelectedArea)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 JSONObject (org.json.simple.JSONObject)1 ParseException (org.json.simple.parser.ParseException)1