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();
}
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");
}
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;
}
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);
}
}
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;
}
Aggregations