Search in sources :

Example 1 with FieldDTO

use of au.org.ala.spatial.dto.FieldDTO in project spatial-portal by AtlasOfLivingAustralia.

the class TabulationComposer method onFinish.

@Override
public boolean onFinish() {
    String f1DisplayName = cbTabLayers1.getSelectedItem().getValue();
    String f2DisplayName = cbTabLayers2.getSelectedItem().getValue();
    String f1Name = "", f2Name = "";
    Iterator<FieldDTO> it = tabLayers.keySet().iterator();
    while (it.hasNext()) {
        FieldDTO fi = it.next();
        if (f1DisplayName.equals(fi.getDisplayName())) {
            f1Name = fi.getName();
        } else if (f2DisplayName.equals(fi.getDisplayName())) {
            f2Name = fi.getName();
        }
    }
    Event e = new Event("tabulation", this, CommonData.getLayersServer() + "/tabulation/" + cbTabType.getSelectedItem().getValue() + "/" + f1Name + "/" + f2Name + "/tabulation.html" + "\n" + StringConstants.TABULATION + "\n" + CommonData.getLayersServer() + "/tabulation/" + cbTabType.getSelectedItem().getValue() + "/" + f1Name + "/" + f2Name + "/tabulation.csv");
    getMapComposer().openUrl(e);
    remoteLogger.logMapAnalysis(StringConstants.TABULATION, "Tool - Tabulation", "", "", f1Name + ":" + f2Name, "", (String) cbTabType.getSelectedItem().getValue(), StringConstants.STARTED);
    this.detach();
    return true;
}
Also used : Event(org.zkoss.zk.ui.event.Event) FieldDTO(au.org.ala.spatial.dto.FieldDTO)

Example 2 with FieldDTO

use of au.org.ala.spatial.dto.FieldDTO in project spatial-portal by AtlasOfLivingAustralia.

the class TabulationComposer method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    this.selectedMethod = StringConstants.TABULATION;
    this.totalSteps = 1;
    this.updateWindowTitle();
    cbTabLayers1.setFocus(true);
    tabLayers = new HashMap<FieldDTO, List<FieldDTO>>();
    tabLayerDisplayNames = new HashMap<String, List<String>>();
    try {
        int i;
        HttpClient client = new HttpClient();
        GetMethod get = new GetMethod(CommonData.getLayersServer() + "/tabulations.json");
        get.addRequestHeader(StringConstants.ACCEPT, StringConstants.APPLICATION_JSON);
        client.executeMethod(get);
        String tlayers = get.getResponseBodyAsString();
        JSONParser jp = new JSONParser();
        JSONObject joTop = (JSONObject) jp.parse(tlayers);
        JSONArray joarr = (JSONArray) joTop.get("tabulations");
        for (i = 0; i < joarr.size(); i++) {
            JSONObject jo = (JSONObject) joarr.get(i);
            FieldDTO f1 = new FieldDTO(jo.get("fid1").toString(), jo.get("name1").toString(), "");
            FieldDTO f2 = new FieldDTO(jo.get("fid2").toString(), jo.get("name2").toString(), "");
            load(f1, f2);
            load(f2, f1);
        }
        Set keySet = (Set) tabLayerDisplayNames.keySet();
        List keyList = new ArrayList(keySet);
        Collections.sort(keyList);
        LOGGER.debug("keyList1=" + keyList);
        for (int j = 0; j < keyList.size(); j++) {
            String temp = (String) keyList.get(j);
            LOGGER.debug("temp=" + temp);
            Comboitem ci = new Comboitem(temp);
            ci.setValue(temp);
            ci.setParent(cbTabLayers1);
        }
        cbTabLayers1.addEventListener("onChange", new EventListener() {

            public void onEvent(Event event) throws Exception {
                onChange$cbTabLayer1(event);
            }
        });
        cbTabLayers1.setSelectedIndex(0);
        onChange$cbTabLayer1(null);
        cbTabLayers2.setSelectedIndex(0);
        cbTabType.setSelectedIndex(0);
    } catch (Exception e) {
        LOGGER.debug("Unable to call tabulation service for a list of layers", e);
    }
}
Also used : JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) Event(org.zkoss.zk.ui.event.Event) JSONParser(org.json.simple.parser.JSONParser) Comboitem(org.zkoss.zul.Comboitem) EventListener(org.zkoss.zk.ui.event.EventListener) FieldDTO(au.org.ala.spatial.dto.FieldDTO)

Example 3 with FieldDTO

use of au.org.ala.spatial.dto.FieldDTO in project spatial-portal by AtlasOfLivingAustralia.

the class TabulationComposer method getField2.

private List<FieldDTO> getField2(FieldDTO f1) {
    List<FieldDTO> f2s = null;
    Iterator<FieldDTO> it = tabLayers.keySet().iterator();
    while (it.hasNext()) {
        FieldDTO fi = it.next();
        if (f1.getName().equals(fi.getName())) {
            f2s = tabLayers.get(fi);
            break;
        }
    }
    return f2s;
}
Also used : FieldDTO(au.org.ala.spatial.dto.FieldDTO)

Aggregations

FieldDTO (au.org.ala.spatial.dto.FieldDTO)3 Event (org.zkoss.zk.ui.event.Event)2 HttpClient (org.apache.commons.httpclient.HttpClient)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 JSONParser (org.json.simple.parser.JSONParser)1 EventListener (org.zkoss.zk.ui.event.EventListener)1 Comboitem (org.zkoss.zul.Comboitem)1