Search in sources :

Example 1 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AddFacetController method onClick$btnOk.

public void onClick$btnOk(Event event) {
    if (btnOk.isDisabled()) {
        return;
    }
    try {
        if (!hasCustomArea && (isAreaCustom() || isAreaHighlightCustom())) {
            this.doOverlapped();
            this.setTop("-9999px");
            this.setLeft("-9999px");
            Map<String, Object> winProps = new HashMap<String, Object>();
            winProps.put(StringConstants.PARENT, this);
            winProps.put(StringConstants.PARENTNAME, "Tool");
            winProps.put(StringConstants.SELECTEDMETHOD, selectedMethod);
            List<MapLayer> layers = getMapComposer().getPolygonLayers();
            if (layers != null && !layers.isEmpty()) {
                prevTopArea = layers.get(0);
            } else {
                prevTopArea = null;
            }
            Window window = (Window) Executions.createComponents("WEB-INF/zul/add/AddArea.zul", this, winProps);
            window.setAttribute("winProps", winProps, true);
            window.setParent(this);
            window.doModal();
            return;
        }
        Div currentDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + currentStep);
        Div nextDiv = (Div) getFellowIfAny(StringConstants.ATSTEP + (currentStep + 1));
        if (!currentDiv.getZclass().contains(StringConstants.LAST)) {
            currentDiv.setVisible(false);
            nextDiv.setVisible(true);
            Html previousStepCompletedImg = (Html) getFellowIfAny(StringConstants.IMG_COMPLETED_STEP + (currentStep));
            previousStepCompletedImg.setVisible(true);
            Label previousStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep));
            previousStepLabel.setStyle(StringConstants.FONT_WEIGHT_NORMAL);
            Label currentStepLabel = (Label) getFellowIfAny(StringConstants.LBLSTEP + (currentStep + 1));
            currentStepLabel.setStyle(StringConstants.FONT_WEIGHT_BOLD);
            currentStep++;
            updateWindowTitle();
            fixFocus();
            sa = getSelectedArea();
            query = QueryUtil.queryFromSelectedArea(query, sa, false, getGeospatialKosher());
            if (query != null) {
                List<QueryField> fields = query.getFacetFieldList();
                Collections.sort(fields, new QueryField.QueryFieldComparator());
                String lastGroup = null;
                for (QueryField field : fields) {
                    String newGroup = field.getGroup().getName();
                    if (!newGroup.equals(lastGroup)) {
                        Comboitem sep = new Comboitem(StringConstants.SEPERATOR);
                        sep.setLabel("---------------" + StringUtils.center(newGroup, 19) + "---------------");
                        sep.setParent(cbColour);
                        sep.setDisabled(true);
                        lastGroup = newGroup;
                    }
                    Comboitem ci = new Comboitem(field.getDisplayName());
                    ci.setValue(field.getName());
                    ci.setParent(cbColour);
                }
            }
            btnBack.setDisabled(false);
            btnOk.setDisabled(true);
        } else {
            if (selectedList.size() == 0) {
                btnOk.setDisabled(true);
            }
            Facet f = Facet.parseFacet(getSelectionFacet());
            Query querynew = query.newFacet(f, true);
            if (querynew.getOccurrenceCount() <= 0) {
                getMapComposer().showMessage(CommonData.lang(StringConstants.NO_OCCURRENCES_SELECTED));
            } else {
                getMapComposer().mapSpecies(querynew, StringConstants.MY_FACET, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
                this.detach();
            }
        }
    } catch (Exception ex) {
        LOGGER.error("error adding facet", ex);
    }
    fixFocus();
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) SuspendNotAllowedException(org.zkoss.zk.ui.SuspendNotAllowedException) QueryField(au.org.ala.legend.QueryField) LegendObject(au.org.ala.legend.LegendObject) Facet(au.org.ala.legend.Facet)

Example 2 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AddFacetController method onClick$dbutton.

public void onClick$dbutton(Event event) {
    uncheckAll();
    minValue = dmin.getValue();
    maxValue = dmax.getValue();
    //get count and display
    Facet f = Facet.parseFacet(getSelectionFacet());
    Query querynew = query.newFacet(f, true);
    lblOccurrencesSelected.setValue(querynew.getOccurrenceCount() + " occurrences selected");
}
Also used : Facet(au.org.ala.legend.Facet)

Example 3 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AreaEnvironmentalEnvelope method getFacets.

List<Facet> getFacets() {
    List<Facet> facets = new ArrayList<Facet>();
    for (int i = 0; i < selectedLayers.size(); i++) {
        SPLFilter splf = selectedSPLFilterLayers.get(selectedLayers.get(i).get(StringConstants.ID));
        Facet f = new Facet(CommonData.getLayerFacetName(splf.getLayername()), splf.getMinimumValue(), splf.getMaximumValue(), true);
        facets.add(f);
    }
    return facets;
}
Also used : ArrayList(java.util.ArrayList) Facet(au.org.ala.legend.Facet)

Example 4 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AreaReportController method onMapSpeciesKosher.

public void onMapSpeciesKosher(Event event) {
    try {
        SelectedArea sa;
        if (!StringConstants.CURRENT_EXTENT.equalsIgnoreCase(areaName)) {
            sa = selectedArea;
        } else {
            sa = new SelectedArea(null, getMapComposer().getViewArea());
        }
        Query baseQuery = null;
        if (event != null && event.getData() != null) {
            baseQuery = new BiocacheQuery(null, null, (String) event.getData(), null, false, null);
        }
        Query query = QueryUtil.queryFromSelectedArea(baseQuery, sa, true, new boolean[] { true, false, false });
        query = query.newFacet(new Facet("occurrence_status_s", "absent", false), false);
        String activeAreaLayerName = getMapComposer().getNextActiveAreaLayerName(areaDisplayName + " geospatial kosher");
        getMapComposer().mapSpecies(query, activeAreaLayerName, StringConstants.SPECIES, -1, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
    } catch (Exception e) {
        LOGGER.error("error mapping kosher species in area", e);
    }
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) Facet(au.org.ala.legend.Facet)

Example 5 with Facet

use of au.org.ala.legend.Facet in project spatial-portal by AtlasOfLivingAustralia.

the class AreaReportController method facetCounts.

Map<String, Object> facetCounts(AreaReportItemDTO pmodel, String facet) {
    org.zkoss.util.Locales.setThreadLocal(null);
    Map<String, AreaReportItemDTO> countsData = new LinkedHashMap<String, AreaReportItemDTO>();
    LOGGER.debug("Starting to get facet counts for : " + facet);
    AreaReportItemDTO dto = pmodel;
    int colonIdx = facet.indexOf(':');
    String query = colonIdx > 0 ? facet : facet + ":*";
    Query sq = QueryUtil.queryFromSelectedArea(null, selectedArea, query, false, new boolean[] { true, true, false });
    sq = sq.newFacet(new Facet("occurrence_status_s", "absent", false), false);
    int count = sq.getSpeciesCount();
    if (count == -1)
        count = 0;
    String label = Labels.getLabel("facet." + facet, facet);
    //title
    dto.setTitle(label);
    //count
    dto.setCount(String.format("%,d", count));
    //check to see if it is a species list
    if (facet.equals(CommonData.speciesListThreatened)) {
        dto.setTitle("Threatened Species");
    } else if (facet.equals(CommonData.speciesListInvasive)) {
        dto.setTitle("Invasive Species");
    } else if (facet.startsWith("species_list") && colonIdx > 0) {
        //extract everything to the right of the colon and construct the url
        String dataResourceUid = facet.substring(colonIdx + 1);
        String title = SpeciesListUtil.getSpeciesListMap().get(dataResourceUid);
        if (title != null) {
            dto.setTitle(title);
        }
        dto.addUrlDetails("Full List", CommonData.getSpeciesListServer() + "/speciesListItem/list/" + dataResourceUid);
    } else if (facet.startsWith("species_group")) {
        dto.setTitle(facet.substring(colonIdx + 1));
    }
    //url
    if (count > 0) {
        dto.addUrlDetails(VIEW_RECORDS, CommonData.getBiocacheWebServer() + "/occurrences/search?q=" + sq.getQ() + (StringUtils.isNotEmpty(sq.getQc()) ? sq.getQc() : ""));
        dto.setExtraParams(query);
        dto.setExtraInfo(new ExtraInfoEnum[] { ExtraInfoEnum.LIST, ExtraInfoEnum.MAP_ALL });
        dto.setListType(ListType.SPECIES);
    }
    countsData.put(facet, dto);
    LOGGER.debug("Facet Counts ::: " + countsData);
    //this data needs to be added to the model on the correct thread...
    return (Map) countsData;
}
Also used : AreaReportItemDTO(au.org.ala.spatial.dto.AreaReportItemDTO) Facet(au.org.ala.legend.Facet)

Aggregations

Facet (au.org.ala.legend.Facet)35 MapLayer (au.org.emii.portal.menu.MapLayer)12 SelectedArea (au.org.emii.portal.menu.SelectedArea)12 JSONObject (org.json.simple.JSONObject)8 ArrayList (java.util.ArrayList)7 JSONParser (org.json.simple.parser.JSONParser)6 ParseException (org.json.simple.parser.ParseException)6 Query (au.org.ala.spatial.util.Query)5 LegendObject (au.org.ala.legend.LegendObject)3 MapLayerMetadata (au.org.emii.portal.menu.MapLayerMetadata)3 Geometry (com.vividsolutions.jts.geom.Geometry)3 IOException (java.io.IOException)3 StringReader (java.io.StringReader)3 HttpClient (org.apache.commons.httpclient.HttpClient)3 PostMethod (org.apache.commons.httpclient.methods.PostMethod)3 JSONArray (org.json.simple.JSONArray)3 CSVReader (au.com.bytecode.opencsv.CSVReader)2 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)2 BiocacheQuery (au.org.ala.spatial.util.BiocacheQuery)2 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)2