use of au.org.ala.spatial.composer.species.SpeciesListListbox in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedSpecies.
public Query getSelectedSpecies(boolean mapspecies, boolean applycheckboxes) {
Query q = null;
if (rgSpecies == null) {
return q;
}
Radio r = rgSpecies.getSelectedItem();
if (r == null) {
if (rgSpecies.getItemCount() == 0) {
return q;
}
LOGGER.error("rgSpecies item is not selected. step=" + currentStep + " method=" + getTitle() + " rgSpeces item at [0]=" + (rgSpecies != null && rgSpecies.getItemCount() > 0 ? rgSpecies.getItemAtIndex(0).getValue() : "null or no species items in list"));
r = rgSpecies.getItemAtIndex(0);
}
String species = r.getValue();
String id = rgSpecies.getSelectedItem().getId();
LOGGER.debug("getSelectedSpecies.species: " + species);
MapLayer ml = getMapComposer().getMapLayer(species);
if (ml != null) {
q = ml.getSpeciesQuery();
q.setName(ml.getDisplayName());
if (q instanceof BiocacheQuery) {
BiocacheQuery bq = (BiocacheQuery) q;
q = bq.newFacetGeospatialKosher(applycheckboxes ? getGeospatialKosher() : null, false);
}
} else {
try {
LOGGER.debug("getSelectedSpecies: " + species);
LOGGER.debug("tool is: " + (tToolName == null ? StringConstants.NULL : tToolName.getValue()));
if ("allspecies".equals(species)) {
q = new BiocacheQuery(null, null, null, null, false, applycheckboxes ? getGeospatialKosher() : null);
} else if (ml == null && "allmapped".equals(species)) {
throw new UnsupportedOperationException("Not yet implemented");
} else if (StringConstants.MULTIPLE.equals(species)) {
String lsids = getMultipleLsids();
LOGGER.debug("getSelectedSpecies.lsids: " + lsids);
if (lsids != null && lsids.length() > 0) {
q = new BiocacheQuery(lsids, null, null, null, false, applycheckboxes ? getGeospatialKosher() : null);
LOGGER.debug("getSelectedSpecies.query is now set");
}
} else if ("uploadLsid".equals(species)) {
//get the query from species list list
SpeciesListListbox lb = id.endsWith("Bk") ? speciesListListboxBk : speciesListListbox;
q = lb.extractQueryFromSelectedLists(applycheckboxes ? getGeospatialKosher() : null);
} else if ((StringConstants.SEARCH.equals(species) || StringConstants.UPLOAD_SPECIES.equals(species)) && searchSpeciesACComp.hasValidItemSelected()) {
try {
q = searchSpeciesACComp.getQuery((Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS), false, applycheckboxes ? getGeospatialKosher() : null);
} catch (Exception e) {
LOGGER.error("autocomplete selection failed value=" + searchSpeciesACComp.getAutoComplete().getSelectedItem().getValue() + " text=" + searchSpeciesACComp.getAutoComplete().getText());
}
if (q != null && "All species".equals(q.getName())) {
q = null;
}
if (!searchSpeciesACComp.hasValidAnnotatedItemSelected()) {
LOGGER.debug("error in getSelectedSpecies value=" + searchSpeciesACComp.getAutoComplete().getSelectedItem().getValue() + " text=" + searchSpeciesACComp.getAutoComplete().getText());
}
} else if ("lifeform".equalsIgnoreCase(species)) {
q = new BiocacheQuery(null, null, null, Arrays.asList(new Facet[] { new Facet("species_group", cbLifeform.getValue(), true) }), mapspecies, applycheckboxes ? getGeospatialKosher() : null);
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected species", e);
}
}
return q;
}
use of au.org.ala.spatial.composer.species.SpeciesListListbox in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedSpeciesName.
public String getSelectedSpeciesName() {
String species = rgSpecies.getSelectedItem().getValue();
try {
if ("allmapped".equals(species)) {
species = "All mapped species";
} else if (StringConstants.SEARCH.equals(species)) {
if (searchSpeciesACComp.hasValidItemSelected()) {
species = searchSpeciesACComp.getAutoComplete().getText();
}
} else if ("uploadLsid".equals(species)) {
//get the query from species list list
String id = rgSpecies.getSelectedItem().getId();
SpeciesListListbox lb = id.endsWith("Bk") ? speciesListListboxBk : speciesListListbox;
species = lb.getSelectedNames();
} else if ("lifeform".equalsIgnoreCase(species)) {
species = cbLifeform.getText();
} else {
species = rgSpecies.getSelectedItem().getLabel();
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected species", e);
}
return species;
}
use of au.org.ala.spatial.composer.species.SpeciesListListbox in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method getSelectedSpeciesBk.
public Query getSelectedSpeciesBk(boolean mapspecies, boolean applycheckboxes) {
Query q = null;
if (rgSpeciesBk == null) {
return q;
}
Radio r = rgSpeciesBk.getSelectedItem();
if (r == null) {
if (rgSpeciesBk.getItemCount() == 0) {
return q;
}
LOGGER.error("rgSpeciesBk item is not selected. step=" + currentStep + " method=" + getTitle() + " rgSpeces item at [0]=" + (rgSpeciesBk != null && rgSpeciesBk.getItemCount() > 0 ? rgSpeciesBk.getItemAtIndex(0).getValue() : "null or no species items in list"));
r = rgSpeciesBk.getItemAtIndex(0);
}
String species = r.getValue();
String id = rgSpeciesBk.getSelectedItem().getId();
MapLayer ml = getMapComposer().getMapLayer(species);
if (ml != null) {
q = ml.getSpeciesQuery();
if (q instanceof BiocacheQuery) {
BiocacheQuery bq = (BiocacheQuery) q;
q = bq.newFacetGeospatialKosher(applycheckboxes ? getGeospatialKosherBk() : null, false);
}
} else {
try {
if ("allspecies".equals(species)) {
q = new BiocacheQuery(null, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
} else if ("allmapped".equals(species)) {
throw new UnsupportedOperationException("Not yet implemented");
} else if (StringConstants.MULTIPLE.equals(species)) {
String lsids = getMultipleLsidsBk();
if (lsids != null && lsids.length() > 0) {
q = new BiocacheQuery(lsids, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
}
} else if ("uploadLsid".equals(species)) {
//get the query from species list list
SpeciesListListbox lb = id.endsWith("Bk") ? speciesListListboxBk : speciesListListbox;
q = lb.extractQueryFromSelectedLists(applycheckboxes ? getGeospatialKosher() : null);
} else if ((StringConstants.SEARCH.equals(species) || StringConstants.UPLOAD_SPECIES.equals(species)) && bgSearchSpeciesACComp.hasValidItemSelected()) {
q = bgSearchSpeciesACComp.getQuery((Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS), false, applycheckboxes ? getGeospatialKosherBk() : null);
}
} catch (Exception e) {
LOGGER.warn("Unable to retrieve selected species", e);
}
}
return q;
}
use of au.org.ala.spatial.composer.species.SpeciesListListbox in project spatial-portal by AtlasOfLivingAustralia.
the class ToolComposer method updateSpeciesListMessage.
public void updateSpeciesListMessage(String drUid) {
//if a data resource exists check report it
LOGGER.debug("Species list that was created : " + drUid);
if (drUid != null) {
boolean isBk = rMultipleBk != null && rMultipleBk.isChecked();
SpeciesListListbox lb = isBk ? speciesListListboxBk : speciesListListbox;
Radio r = isBk ? rSpeciesUploadLSIDBk : rSpeciesUploadLSID;
((SpeciesListListbox.SpeciesListListModel) lb.getModel()).refreshModel();
r.setSelected(true);
if (isBk) {
onCheck$rgSpeciesBk(null);
} else {
onCheck$rgSpecies(null);
}
}
}
Aggregations