use of au.org.ala.spatial.util.UserDataQuery in project spatial-portal by AtlasOfLivingAustralia.
the class ScatterplotLayerLegendComposer method setupCBColour.
private void setupCBColour(Query q) {
for (int i = cbColour.getItemCount() - 1; i >= 0; i--) {
if (cbColour.getItemAtIndex(i) != ciColourUser) {
cbColour.removeItemAt(i);
}
}
if (q != null) {
List<QueryField> fields = query.getFacetFieldList();
Collections.sort(fields, new QueryField.QueryFieldComparator());
String lastGroup = null;
for (QueryField field : fields) {
if (field.getFieldType() == QueryField.FieldType.STRING && (q instanceof UserDataQuery || !(StringConstants.OCCURRENCE_YEAR.equalsIgnoreCase(field.getName()) || StringConstants.COORDINATE_UNCERTAINTY.equalsIgnoreCase(field.getName()) || StringConstants.MONTH.equalsIgnoreCase(field.getName())))) {
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);
}
}
}
}
use of au.org.ala.spatial.util.UserDataQuery in project spatial-portal by AtlasOfLivingAustralia.
the class UploadSpeciesController method loadUserPoints.
public static void loadUserPoints(UserDataDTO ud, Reader data, boolean addToMap, String name, String description, MapComposer mc, EventListener eventListener) throws Exception {
LOGGER.debug("\n\n\nin loadUserPoints");
// Read a line in to check if it's a valid file
// if it throw's an error, then it's not a valid csv file
StringBuilder sbProcessUrl = new StringBuilder();
sbProcessUrl.append(CommonData.getLayersServer()).append("/userdata/add");
//TODO: get signed in user's id
sbProcessUrl.append("?user_id=").append("anonymous");
sbProcessUrl.append("&name=").append(URLEncoder.encode(name, StringConstants.UTF_8));
sbProcessUrl.append("&description=").append(URLEncoder.encode(description, StringConstants.UTF_8));
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(sbProcessUrl.toString());
post.addRequestHeader(StringConstants.ACCEPT, StringConstants.APPLICATION_JSON);
post.addParameter("csv", IOUtils.toString(data));
LOGGER.debug("calling add user data ws: " + sbProcessUrl.toString());
client.executeMethod(post);
JSONObject jo = (JSONObject) new JSONParser().parse(post.getResponseBodyAsString());
//this is loading user data there is no need for ud_header_id + facet_id for use in layer creation.
UserDataQuery q = new UserDataQuery(String.valueOf(jo.get("ud_header_id")));
if (addToMap) {
MapLayer ml = mc.mapSpecies(q, ud.getName(), "user", ud.getFeatureCount(), LayerUtilitiesImpl.SPECIES_UPLOAD, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), false);
if (ml != null) {
ml.getMapLayerMetadata().setMoreInfo(q.getMetadataHtml());
}
}
if (eventListener != null) {
eventListener.onEvent(new Event("", null, jo.get("ud_header_id") + "\t" + ud.getName()));
}
data.close();
}
Aggregations