Search in sources :

Example 1 with UserDataQuery

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);
            }
        }
    }
}
Also used : UserDataQuery(au.org.ala.spatial.util.UserDataQuery) QueryField(au.org.ala.legend.QueryField)

Example 2 with UserDataQuery

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();
}
Also used : UserDataQuery(au.org.ala.spatial.util.UserDataQuery) JSONObject(org.json.simple.JSONObject) PostMethod(org.apache.commons.httpclient.methods.PostMethod) HttpClient(org.apache.commons.httpclient.HttpClient) MapLayer(au.org.emii.portal.menu.MapLayer) Event(org.zkoss.zk.ui.event.Event) ForwardEvent(org.zkoss.zk.ui.event.ForwardEvent) UploadEvent(org.zkoss.zk.ui.event.UploadEvent) JSONParser(org.json.simple.parser.JSONParser)

Aggregations

UserDataQuery (au.org.ala.spatial.util.UserDataQuery)2 QueryField (au.org.ala.legend.QueryField)1 MapLayer (au.org.emii.portal.menu.MapLayer)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 PostMethod (org.apache.commons.httpclient.methods.PostMethod)1 JSONObject (org.json.simple.JSONObject)1 JSONParser (org.json.simple.parser.JSONParser)1 Event (org.zkoss.zk.ui.event.Event)1 ForwardEvent (org.zkoss.zk.ui.event.ForwardEvent)1 UploadEvent (org.zkoss.zk.ui.event.UploadEvent)1