use of au.org.ala.spatial.util.BiocacheQuery in project spatial-portal by AtlasOfLivingAustralia.
the class ExportSpeciesExternalComposer method onFinish.
@Override
public boolean onFinish() {
List<Query> list = getAllSelectedSpecies();
List<Map> maps = new ArrayList<>();
for (Query q : list) {
Map m = new HashMap();
m.put("name", q.getName());
m.put("query", "qid:" + ((BiocacheQuery) q).getQid());
m.put("url", q.getBS());
maps.add(m);
}
Map container = new HashMap();
container.put("data", maps);
String json = JSONObject.toJSONString(container);
getMapComposer().getOpenLayersJavascript().execute("postToExternal('" + CommonData.getSettings().getProperty("bccvl.post.url") + "', " + json + ");");
login(null);
loggingIn = false;
return true;
}
use of au.org.ala.spatial.util.BiocacheQuery in project spatial-portal by AtlasOfLivingAustralia.
the class ClassificationLegend method getSelectionFacet.
String getSelectionFacet() {
StringBuilder values = new StringBuilder();
boolean unknown = false;
for (Object selectedItem : selectedList) {
String v = (String) selectedItem;
v = displayToActualLabel(v);
if (legendFacets != null && !StringConstants.UNKNOWN.equals(v) && !v.contains(StringConstants.OCCURRENCE_YEAR) && !v.contains(StringConstants.UNCERTAINTY) && !v.contains(StringConstants.COORDINATE_UNCERTAINTY)) {
v = legendFacets.get(v);
}
if (v.length() == 0 || ((query instanceof BiocacheQuery || divContinous.isVisible()) && StringConstants.UNKNOWN.equals(v))) {
unknown = true;
} else {
if (values.length() > 0) {
values.append(" OR ");
}
if (legendFacets != null) {
values.append(v);
} else {
values.append(colourmode).append(":\"");
values.append(v).append("\"");
}
}
}
String unknownSearch = divContinous.isVisible() ? ":[* TO *]" : ":*";
if (unknown) {
if (values.length() > 0) {
String newValues = "-(" + colourmode + unknownSearch + " AND -" + values.toString().replace(" OR ", " AND -") + ")";
values = new StringBuilder();
values.append(newValues);
} else {
values.append("-").append(colourmode).append(unknownSearch);
}
}
if (values.length() == 0 && (minValue != gMinValue || maxValue != gMaxValue || !dunknown.isChecked())) {
if (dunknown.isChecked()) {
if (intContinous) {
values.append(String.format("-(%s:[* TO *] AND -%s:[%d TO %d])", colourmode, colourmode, (int) minValue, (int) maxValue));
} else {
values.append(String.format("-(%s:[* TO *] AND -%s:[%f TO %f])", colourmode, colourmode, minValue, maxValue));
}
} else {
if (intContinous) {
values.append(String.format("%s:[%d TO %d]", colourmode, (int) minValue, (int) maxValue));
} else {
values.append(String.format("%s:[%f TO %f]", colourmode, minValue, maxValue));
}
}
}
if (values.length() > 0) {
facet = Facet.parseFacet(values.toString());
return facet.toString();
} else {
facet = null;
return "";
}
}
use of au.org.ala.spatial.util.BiocacheQuery in project spatial-portal by AtlasOfLivingAustralia.
the class SandboxPasteController method gotDrUid.
public void gotDrUid(Event event) {
dataResourceUid = ((String) event.getData());
sandboxReady.setVisible(true);
sandboxFrame.setVisible(false);
List<Facet> facetList = new ArrayList<Facet>();
facetList.add(new Facet("data_resource_uid", dataResourceUid, true));
query = new BiocacheQuery(null, null, null, facetList, true, null, CommonData.getSettings().getProperty("sandbox.biocache.url"), CommonData.getSettings().getProperty("sandbox.biocache.ws.url"), true);
if (addtoMap) {
getMapComposer().mapSpecies(query, query.getSolrName(), StringConstants.SPECIES, query.getOccurrenceCount(), LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
}
// call reset window on caller to perform refresh'
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", null, null, new String[] { dataResourceUid, "normal" }));
} catch (Exception e) {
LOGGER.error("failed to cancel species points upload", e);
}
}
onClick$btnOk(null);
}
use of au.org.ala.spatial.util.BiocacheQuery in project spatial-portal by AtlasOfLivingAustralia.
the class SamplingComposer method download.
public boolean download(Event event) {
try {
SelectedArea sa = getSelectedArea();
Query query = QueryUtil.queryFromSelectedArea(getSelectedSpecies(), sa, false, getGeospatialKosher());
// test size
if (query.getOccurrenceCount() <= 0) {
getMapComposer().showMessage("No occurrences selected. Please try again", this);
return false;
}
// translate layer names
String[] layers = null;
String[] layersDisplaynames = null;
String envlayers = getSelectedLayersWithDisplayNames();
if (envlayers.length() > 0) {
layers = envlayers.split(":");
layersDisplaynames = new String[layers.length];
for (int i = 0; i < layers.length; i++) {
String[] l = layers[i].split("\\|");
String newName = CommonData.getLayerFacetName(l[0]);
layers[i] = newName;
layersDisplaynames[i] = l[1];
}
}
if (query instanceof BiocacheQuery) {
String[] inBiocache = null;
String[] outBiocache;
String[] outBiocacheDN;
// split layers into 'in biocache' and 'out of biocache'
Set<String> biocacheLayers = CommonData.getBiocacheLayerList();
List<String> aInBiocache = new ArrayList<String>();
List<String> aOutBiocache = new ArrayList<String>();
List<String> aInBiocacheDN = new ArrayList<String>();
List<String> aOutBiocacheDN = new ArrayList<String>();
if (layers != null) {
for (int i = 0; i < layers.length; i++) {
String s = layers[i];
if (biocacheLayers.contains(s)) {
aInBiocache.add(s);
aInBiocacheDN.add(layersDisplaynames[i]);
} else {
aOutBiocache.add(s);
aOutBiocacheDN.add(layersDisplaynames[i]);
}
}
}
if (!aInBiocache.isEmpty()) {
inBiocache = new String[aInBiocache.size()];
aInBiocache.toArray(inBiocache);
}
if (!aOutBiocache.isEmpty()) {
outBiocache = new String[aOutBiocache.size()];
aOutBiocache.toArray(outBiocache);
outBiocacheDN = new String[aOutBiocacheDN.size()];
aOutBiocacheDN.toArray(outBiocacheDN);
getMapComposer().setDownloadSecondQuery(query);
getMapComposer().setDownloadSecondLayers(outBiocache, outBiocacheDN);
SamplingAnalysisDownloadController c = (SamplingAnalysisDownloadController) Executions.createComponents("/WEB-INF/zul/output/SamplingAnalysisDownload.zul", getMapComposer(), null);
c.setParent(getMapComposer());
c.doModal();
} else {
getMapComposer().setDownloadSecondQuery(null);
getMapComposer().setDownloadSecondLayers(null, null);
}
// test for URL download
String url = query.getDownloadUrl(inBiocache);
LOGGER.debug("Sending file to user: " + url);
Events.echoEvent(StringConstants.OPEN_HTML, getMapComposer(), "Download\n" + url);
try {
remoteLogger.logMapAnalysis("species sampling", "Export - Species Sampling", sa.getWkt(), query.getName(), envlayers, pid, "", "download");
} catch (Exception e) {
LOGGER.error("remote logger error", e);
}
this.detach();
} else {
String fileUrl = query.getDownloadUrl(layers);
Filedownload.save(new URL(fileUrl).openStream(), "application/zip", query.getName().replaceAll(" ", "_") + "_sample_" + ".zip");
try {
remoteLogger.logMapAnalysis("species sampling", "Export - Species Sampling", sa.getWkt(), query.getName(), envlayers, pid, "", "");
} catch (Exception e) {
LOGGER.error("remote logger error", e);
}
this.detach();
}
return true;
} catch (Exception e) {
LOGGER.error("Exception calling sampling.download:", e);
getMapComposer().showMessage("Unknown error.", this);
}
return false;
}
use of au.org.ala.spatial.util.BiocacheQuery in project spatial-portal by AtlasOfLivingAustralia.
the class SandboxEmbeddedController method gotDrUid.
public void gotDrUid(Event event) {
dataResourceUid = ((String) event.getData());
sandboxReady.setVisible(true);
sandboxFrame.setVisible(false);
List<Facet> facetList = new ArrayList<Facet>();
facetList.add(new Facet("data_resource_uid", dataResourceUid, true));
query = new BiocacheQuery(null, null, null, facetList, true, null, CommonData.getSettings().getProperty("sandbox.biocache.url"), CommonData.getSettings().getProperty("sandbox.biocache.ws.url"), true);
if (addtoMap) {
getMapComposer().mapSpecies(query, query.getSolrName(), StringConstants.SPECIES, query.getOccurrenceCount(), LayerUtilitiesImpl.SPECIES, null, 0, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
}
// call reset window on caller to perform refresh'
if (callback != null) {
try {
callback.onEvent(new ForwardEvent("", null, null, new String[] { dataResourceUid, "normal" }));
} catch (Exception e) {
LOGGER.error("failed to cancel species points upload", e);
}
}
onClick$btnOk(null);
}
Aggregations