Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encode.

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

From source file:org.freemedsoftware.gwt.client.screen.patient.AllergyEntryScreen.java

License:Open Source License

public void saveForm() {
    data.put("patient", patientScreen.getPatient().toString());

    data.put("allergy", allergyTextBox.getText());
    data.put("reaction", reactionTextBox.getText());
    data.put("severity", severityTextBox.getText());

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        Util.showInfoMsg(className, _("Allergy added."));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(data) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Allergies.add", params)));
        try {//from www  . ja  v a  2 s. c om
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg(className, _("Failed to add allergy."));
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        Integer r = (Integer) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()),
                                "Integer");
                        if (r != null) {
                            Util.showInfoMsg(className, _("Allergy added."));
                            patientScreen.getSummaryScreen().populateClinicalInformation();
                        }
                    } else {
                        Util.showErrorMsg(className, _("Failed to add allergy."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg(className, _("Failed to add allergy."));
        }
    } else {
        // TODO: GWT-RPC Stuff
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.AllergyEntryScreen.java

License:Open Source License

public void populate() {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(patientId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Allergies.GetMostRecent", params)));
        try {/* w w w.  java  2  s  . c o  m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        @SuppressWarnings("unchecked")
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            allergyTextBox.setText(r[0].get("allergy"));
                            reactionTextBox.setText(r[0].get("reaction"));
                            severityTextBox.setText(r[0].get("severity"));
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.ClinicalOrdersEntry.java

License:Open Source License

public void save() {
    HashMap<String, String> data = new HashMap<String, String>();
    data.put("patient", Integer.toString(patientId));

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: STUBBED
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // JSON-RPC
        String[] params = { JsonUtil.jsonify(data) };

        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ClinicalOrders.add", params)));
        try {/* w  ww  .  j ava2s.  com*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add order."));
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        if (response.getText().compareToIgnoreCase("false") != 0) {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) { // Successful
                                Util.showInfoMsg("ClinicalOrdersEntry", _("Successfully added order."));
                            }
                        } else {
                            JsonUtil.debug("Received dummy response from JSON backend");
                        }
                    } else {
                        Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add orders."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add orders."));
        }

    } else {
        // GWT-RPC
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void loadEncountersList() {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {

        String[] params = { patientId.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.getEncountersList", params)));

        try {//from   w w  w  . j a va2  s  . c  om
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                enotesCustomTable.loadData(r);
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void laodEncounterNoteInfo(String id) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { id };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.getEncounterNoteInfo", params)));

        try {/* w  ww  .j  av a2  s  .co m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) {
                                moddata = r;
                                if (r.get("pnotestemplate") == null || r.get("pnotestemplate").equals("")
                                        || r.get("pnotestemplate").equals("0")) {

                                    entryVerticalPanel.clear();
                                    createEncounterNotesAdditionTab();

                                } else {
                                    getTemplateValues(moddata.get("pnotestemplate"));
                                }
                            } else {
                            }
                        } catch (Exception e) {
                        }

                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void getTemplateValues(String templateId) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { templateId };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util
                .getJsonRequest("org.freemedsoftware.module.EncounterNotesTemplate.getTemplateInfo", params)));

        try {//from  w w w . j  a  v a  2  s . c  o  m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) {
                                String secStr = r.get("pnotestsections");
                                sections = (HashMap<String, List<String>>) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(secStr), "HashMap<String,List>");
                                entryVerticalPanel.clear();
                                createEncounterNotesAdditionTab();
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void deleteNote(String id) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { id };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.del", params)));

        try {/*from   w  w w .  j a  v a 2  s  .c  o m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            Boolean r = (Boolean) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean");
                            if (r) {
                                Util.showInfoMsg("EncounterNotes", _("Encounter Note successfully deleted."));
                                loadEncountersList();
                            }

                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.GrowthChartScreen.java

License:Open Source License

public void populateStockData(boolean height, final GrowthChart chart) {
    Boolean infant = false;/*  www. j a v  a  2 s  .  c om*/
    if (getMonthsAge(birthDate) < 36) {
        infant = true;
    } else {
        infant = false;
    }

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { gender, JsonUtil.jsonify(height), JsonUtil.jsonify(infant) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.GrowthCharts.GetGrowthChartValues", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("GrowthCharts", "Failed to retrieve stock growth chart data.");
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode() || response.getText() == "false") {
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            chart.setStockData(r);
                            chart.drawStockCurves();
                        }
                    } else {
                        Util.showErrorMsg("GrowthCharts", _("Failed to retrieve stock growth chart data."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("GrowthCharts", _("Failed to retrieve stock growth chart data."));
        }
    } else {
        JsonUtil.debug("Unimplemented GrowthCharts RPC");
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.PatientReportingScreen.java

License:Open Source License

public void populate() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: handle stubbed
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { locale };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientReporting.GetReports", params)));
        try {/*from   ww w . j a  va  2 s.  co m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(com.google.gwt.http.client.Request request, Throwable ex) {
                    GWT.log("Exception", ex);
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(com.google.gwt.http.client.Request request,
                        com.google.gwt.http.client.Response response) {
                    if (200 == response.getStatusCode()) {
                        HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (result != null) {
                            reportTable.loadData(result);
                        } else {
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            GWT.log("Exception", e);
        }
    } else {
        // TODO: Not done yet
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.PatientReportingScreen.java

License:Open Source License

/**
 * Get parameters for a specific report by uuid.
 * //w ww  . jav  a  2 s.  c  o m
 * @param uuid
 */
public void getReportInformation(String uuid) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: handle stubbed
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { uuid };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util
                .getJsonRequest("org.freemedsoftware.module.PatientReporting.GetReportParameters", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(com.google.gwt.http.client.Request request, Throwable ex) {
                    GWT.log("Exception", ex);
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(com.google.gwt.http.client.Request request,
                        com.google.gwt.http.client.Response response) {
                    if (200 == response.getStatusCode()) {
                        HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                        if (result != null) {
                            populateReportParameters(result);
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            GWT.log("Exception", e);
        }
    } else {
        // TODO: Not done yet.
    }
}