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.ClaimsManager.java

License:Open Source License

public void getProcDetails() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {

        String[] params = { currentProcId.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.getProcInfo", params)));
        try {//from www  .j  av  a  2s.  c o m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Window.alert(ex.toString());
                }

                public void onResponseReceived(Request request, Response response) {

                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            try {
                                @SuppressWarnings("unchecked")
                                HashMap<String, String> result = (HashMap<String, String>) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(response.getText()),
                                                "HashMap<String,String>");

                                procDetailFlexTable.clear();
                                int col = 0;
                                Label procDateLb = new Label(_("Procedure Date"));
                                procDateLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label procDateVal = new Label(result.get("proc_date"));
                                procDetailFlexTable.setWidget(0, col, procDateLb);
                                FlexCellFormatter cellFormatter = procDetailFlexTable.getFlexCellFormatter();
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, procDateVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                Label procCode = new Label(_("Procedure Code"));
                                procCode.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label procCodeVal = new Label(result.get("proc_code"));
                                procDetailFlexTable.setWidget(0, col, procCode);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, procCodeVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                Label provLb = new Label(_("Provider"));
                                provLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label provVal = new Label(result.get("prov_name"));
                                procDetailFlexTable.setWidget(0, col, provLb);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, provVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                Label chargedLb = new Label(_("Charged"));
                                chargedLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label chargedVal = new Label(result.get("proc_obal"));
                                procDetailFlexTable.setWidget(0, col, chargedLb);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, chargedVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                if (result.get("proc_allowed") != null
                                        && !result.get("proc_allowed").equals("")) {
                                    Label allowedLb = new Label(_("Allowed"));
                                    allowedLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                    Label allowedVal = new Label(result.get("proc_allowed"));
                                    procDetailFlexTable.setWidget(0, col, allowedLb);
                                    cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                    procDetailFlexTable.setWidget(1, col, allowedVal);
                                    cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                    col++;
                                }

                                Label chargesLb = new Label(_("Charges"));
                                chargesLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label chargesVal = new Label(result.get("proc_charges"));
                                procDetailFlexTable.setWidget(0, col, chargesLb);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, chargesVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                Label procPaidLb = new Label(_("Paid"));
                                procPaidLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label procPaidVal = new Label(result.get("proc_paid"));
                                procDetailFlexTable.setWidget(0, col, procPaidLb);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, procPaidVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                Label balanceLb = new Label(_("Balance"));
                                balanceLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                Label balanceVal = new Label(result.get("proc_currbal"));
                                procDetailFlexTable.setWidget(0, col, balanceLb);
                                cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                procDetailFlexTable.setWidget(1, col, balanceVal);
                                cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                col++;

                                if (result.get("proc_billed").equals("1")) {
                                    Label billedLb = new Label(_("Billed"));
                                    billedLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                    Label billedVal = new Label(_("Yes"));
                                    procDetailFlexTable.setWidget(0, col, billedLb);
                                    cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                    procDetailFlexTable.setWidget(1, col, billedVal);
                                    cellFormatter.setStyleName(1, 8, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                    col++;

                                    Label dateBilledLb = new Label(_("Date Billed"));
                                    dateBilledLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                    Label dateBilledVal = new Label(result.get("proc_billdate"));
                                    procDetailFlexTable.setWidget(0, col, dateBilledLb);
                                    cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                    procDetailFlexTable.setWidget(1, col, dateBilledVal);
                                    cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                    col++;
                                } else {
                                    Label billedLb = new Label(_("Billed"));
                                    billedLb.setStyleName(AppConstants.STYLE_LABEL_NORMAL_BOLD);
                                    Label billedVal = new Label(_("No"));
                                    procDetailFlexTable.setWidget(0, col, billedLb);
                                    cellFormatter.setStyleName(0, col, AppConstants.STYLE_TABLE_HEADER);
                                    procDetailFlexTable.setWidget(1, col, billedVal);
                                    cellFormatter.setStyleName(1, col, AppConstants.STYLE_TABLE_ROW_ALTERNATE);
                                    col++;
                                }

                            } catch (Exception e) {

                            }
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }
    } else {
    }
}

From source file:org.freemedsoftware.gwt.client.screen.ClaimsManager.java

License:Open Source License

@SuppressWarnings("unchecked")
protected void refreshSearch() {
    final BlockScreenWidget blockScreenWidget = new BlockScreenWidget(_("Loading claims, please wait..."));
    verticalPanel.add(blockScreenWidget);
    claimsManagerTable.clearData();/*from  w w  w .j  a v  a2  s . c o  m*/
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        HashMap<String, String> a = new HashMap<String, String>();
        a.put("item_type", "item type1");
        a.put("item", "item 1");
        a.put("patient", "def");
        a.put("provider", "JEFF");
        a.put("date_of", "1979-08-10");
        a.put("total_balance", "28");
        a.put("payment_date", "1979-09-10");
        a.put("procedure_id", "22");
        a.put("money_out", "200");
        a.put("money_in", "500");
        a.put("id", "1");

        List<HashMap<String, String>> l = new ArrayList<HashMap<String, String>>();
        l.add(a);
        claimsManagerTable.loadData((HashMap<String, String>[]) l.toArray(new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        existingCriteriaTable.clear();
        existingCriteriaTable.removeAllRows();
        selectedProcs.clear();
        selectedBillKeys.clear();
        checkBoxesList.clear();
        HashMap<String, String> criteria = new HashMap<String, String>();
        boolean isAgingSelected = false;
        if (rb120Plus.getValue()) {
            criteria.put("aging", "120+");
            addExistingSearchCriteria("aging", _("Aging"), "120+");
            isAgingSelected = true;
        }
        if (rb91To120.getValue()) {
            criteria.put("aging", "91-120");
            addExistingSearchCriteria("aging", _("Aging"), "91-120");
            isAgingSelected = true;
        }
        if (rb61To90.getValue()) {
            criteria.put("aging", "61-90");
            addExistingSearchCriteria("aging", _("Aging"), "61-90");
            isAgingSelected = true;
        }
        if (rb31To60.getValue()) {
            criteria.put("aging", "31-60");
            addExistingSearchCriteria("aging", _("Aging"), "31-60");
            isAgingSelected = true;
        }
        if (rb0To30.getValue()) {
            criteria.put("aging", "0-30");
            addExistingSearchCriteria("aging", _("Aging"), "0-30");
            isAgingSelected = true;
        }
        if (isAgingSelected) {
            panelAging.setVisible(false);
            lblAging.setVisible(false);
            rb120Plus.setVisible(false);
            rb91To120.setVisible(false);
            rb61To90.setVisible(false);
            rb31To60.setVisible(false);
            rb0To30.setVisible(false);
            rbNoSearch.setVisible(false);
        }

        if (facilityWidget.getStoredValue() != null && !facilityWidget.getStoredValue().equals("0")) {
            criteria.put("facility", facilityWidget.getStoredValue());
            facilityWidget.setVisible(false);
            lblFacility.setVisible(false);
            addExistingSearchCriteria("facility", _("Facility"), facilityWidget.getText());
        }
        if (provWidget.getStoredValue() != null && !provWidget.getStoredValue().equals("0")) {
            criteria.put("provider", provWidget.getStoredValue());
            provWidget.setVisible(false);
            lblProvider.setVisible(false);
            addExistingSearchCriteria("provider", _("Provider"), provWidget.getText());
        }
        if (payerWidget.getStoredValue() != null && !payerWidget.getStoredValue().equals("0")) {
            criteria.put("payer", payerWidget.getStoredValue());
            lblPayer.setVisible(false);
            payerWidget.setVisible(false);
            addExistingSearchCriteria("payer", _("Payer"), payerWidget.getText());
        }
        if (planWidget.getStoredValue() != null && !planWidget.getStoredValue().equals("0")) {
            criteria.put("plan", planWidget.getStoredValue());
            lblPlanName.setVisible(false);
            planWidget.setVisible(false);
            addExistingSearchCriteria("plan", _("Plan Name"), planWidget.getText());
        }
        if (patientWidget.getStoredValue() != null && !patientWidget.getStoredValue().equals("0")) {
            criteria.put("patient", patientWidget.getStoredValue());
            lbPatientWidget.setVisible(false);
            patientWidget.setVisible(false);
            addExistingSearchCriteria("patient", _("Patient Full Name"), patientWidget.getText());
        }
        criteria.put("first_name", txtFirstName.getValue());
        if (!txtFirstName.getText().equals("")) {
            addExistingSearchCriteria("first_name", _("First Name"), txtFirstName.getText());
        }
        criteria.put("last_name", txtLastName.getValue());
        if (!txtLastName.getText().equals("")) {
            addExistingSearchCriteria("last_name", _("Last Name"), txtLastName.getText());
        }
        if (tagWidget.getValue() != null && !tagWidget.getValue().equals("")) {
            addExistingSearchCriteria("tag", _("Tag"), tagWidget.getValue());
            criteria.put("tag", tagWidget.getValue());
            tagWidget.setVisible(false);
            lbTagSearch.setVisible(false);
        }
        if (rbQueued.getValue()) {
            criteria.put("billed", "0");
            statusHp.setVisible(false);
            lblBillingStatus.setVisible(false);
            rbQueued.setVisible(false);
            rbBilled.setVisible(false);
            addExistingSearchCriteria("billed", _("Billing Status"), _("Queued"));
        }
        if (rbBilled.getValue()) {
            criteria.put("billed", "1");
            statusHp.setVisible(false);
            lblBillingStatus.setVisible(false);
            rbQueued.setVisible(false);
            rbBilled.setVisible(false);
            addExistingSearchCriteria("billed", _("Billing Status"), _("Billed"));
        }
        // Check for date of Service.
        if (dateBox.getValue() == null || dateBox.getValue().equals("")) {

        } else {
            criteria.put("date", dateBox.getTextBox().getValue());
            lblDateOfService.setVisible(false);
            dateBox.setVisible(false);
            addExistingSearchCriteria("date", _("Procedures On"), dateBox.getTextBox().getText());
        }
        if (cbShowZeroBalance.getValue()) {
            criteria.put("zerobalance", "1");
            cbShowZeroBalance.setVisible(false);
            addExistingSearchCriteria("zerobalance", _("Include Zero Balance"), "");
        }
        if (cbWholeWeek.getValue()) {
            criteria.put("week", "1");
            cbWholeWeek.setVisible(false);
            addExistingSearchCriteria("week", "Select Week", "");
        }
        String[] params = { JsonUtil.jsonify(criteria) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.AgingReportQualified", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    verticalPanel.remove(blockScreenWidget);
                    Window.alert(ex.toString());
                }

                public void onResponseReceived(Request request, Response response) {

                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            try {
                                HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(response.getText()),
                                                "HashMap<String,String>[]");

                                if (result.length > 0) {
                                    claimsManagerTable.setVisible(true); // FIXME
                                    // old
                                    // value:
                                    // claimsManagerTable.setVisible(false);
                                } else {
                                    claimsManagerTable.setVisible(true);
                                }
                                verticalPanel.remove(blockScreenWidget);
                                claimsManagerTable.loadData(result);
                            } catch (Exception e) {
                                verticalPanel.remove(blockScreenWidget);
                            }
                        } else {
                            verticalPanel.remove(blockScreenWidget);
                            claimsManagerTable.setVisible(false); // FIXME
                            // old
                            // value:
                            // claimsManagerTable.setVisible(true);
                        }
                    }
                }
            });
        } catch (RequestException e) {
            verticalPanel.remove(blockScreenWidget);
            Window.alert(e.toString());
            claimsManagerTable.setVisible(true);
        }
    } else {
        verticalPanel.remove(blockScreenWidget);
    }
}

From source file:org.freemedsoftware.gwt.client.screen.ClaimsManager.java

License:Open Source License

public void markAsBilled() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {

    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { selectedProcs.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.ClaimLog.MarkClaimsAsBilled", params)));
        try {//from   w w  w . j av  a2s .c  o m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Window.alert(ex.toString());
                }

                public void onResponseReceived(Request request, Response response) {

                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            try {
                                refreshSearch();

                            } catch (Exception e) {

                            }
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }

    } else {
    }
}

From source file:org.freemedsoftware.gwt.client.screen.ConfigurationScreen.java

License:Open Source License

protected void commitValues() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        Util.showInfoMsg("ConfigurationScreen", _("Updated configuration."));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(getAllValues()) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.SystemConfig.SetValues", params)));
        try {//from  ww  w.  j av a 2  s.  com
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("ConfigurationScreen", _("Failed to update configuration."));
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        Boolean r = (Boolean) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()),
                                "Boolean");
                        if (r.booleanValue()) {
                            Util.showInfoMsg("ConfigurationScreen", _("Updated configuration."));
                            CurrentState.retrieveSystemConfiguration(true);//re-evaluate system configuration
                            closeScreen();
                        } else {
                            Util.showErrorMsg("ConfigurationScreen", _("Failed to update configuration."));
                        }
                    } else {
                        Util.showErrorMsg("ConfigurationScreen", _("Failed to update configuration."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("ConfigurationScreen", _("Failed to update configuration."));
        }
    } else {
        getProxy().SetValues(getAllValues(), new AsyncCallback<Boolean>() {
            public void onSuccess(Boolean result) {
                if (result.booleanValue()) {
                    Util.showInfoMsg("ConfigurationScreen", _("Updated configuration."));
                } else {
                    Util.showErrorMsg("ConfigurationScreen", _("Failed to update configuration."));
                }
            }

            public void onFailure(Throwable t) {
                GWT.log("Exception", t);
            }
        });
    }
}

From source file:org.freemedsoftware.gwt.client.screen.ConfigurationScreen.java

License:Open Source License

public void populate() {
    containers = new HashMap<String, FlexTable>();
    widgets = new HashMap<String, Widget>();
    containerWidgetCount = new HashMap<String, Integer>();

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: Simulate
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = {};//from   w  w w  .ja va2s .  co  m
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.api.SystemConfig.GetConfigSections", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        String[] r = (String[]) JsonUtil
                                .shoehornJson(JSONParser.parseStrict(response.getText()), "String[]");
                        // Create the actual tabs
                        createTabs(r);
                        tabPanel.selectTab(0);

                        // Fire off population routine
                        populateConfig();
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }
    } else {
        getProxy().GetConfigSections(new AsyncCallback<String[]>() {
            public void onSuccess(String[] r) {
                // Create the actual tabs
                createTabs(r);

                // Fire off population routine
                populateConfig();
            }

            public void onFailure(Throwable t) {
                GWT.log("Exception", t);
            }
        });
    }
}

From source file:org.freemedsoftware.gwt.client.screen.ConfigurationScreen.java

License:Open Source License

protected void populateConfig() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: populate config values
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = {};/*  w  w w  .j  ava2  s. com*/
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.api.SystemConfig.GetAll", params)));
        try {
            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()) {
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        for (int iter = 0; iter < r.length; iter++) {
                            try {
                                addToStack(r[iter]);
                            } catch (Exception ex) {
                                JsonUtil.debug(ex.getMessage());
                            }
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.toString());
        }
    } else {
        getProxy().GetAll(new AsyncCallback<HashMap<String, String>[]>() {
            public void onSuccess(HashMap<String, String>[] r) {
                for (int iter = 0; iter < r.length; iter++) {
                    addToStack(r[iter]);
                }
            }

            public void onFailure(Throwable t) {
                GWT.log("Exception", t);
            }
        });
    }
}

From source file:org.freemedsoftware.gwt.client.screen.entry.ClinicRegistrationEntry.java

License:Open Source License

public void submitForm() {
    ModuleInterfaceAsync service = getProxy();
    // Form hashmap ...
    final HashMap<String, String> rec = new HashMap<String, String>();
    /*/*from   www .ja  v  a 2s. c o  m*/
    Iterator<String> iter = setters.keySet().iterator();
    while (iter.hasNext()) {
       String k = iter.next();
       JsonUtil.debug("grabbing key " + k + " from setters");
       try {
    rec.put(k, setters.get(k).getStoredValue());
       } catch (Exception ex) {
    JsonUtil.debug("key " + k + ": " + ex.toString());
       }
    }
    */

    if (wDateOfBirth.getStoredValue() != null) {
        rec.put("dob", wDateOfBirth.getStoredValue());
    }
    rec.put("lastname", wLastName1.getValue());
    rec.put("lastname2", wLastName2.getValue());
    rec.put("firstname", wFirstName.getValue());
    rec.put("notes", wNotes.getValue());
    if (wGender.getWidgetValue() != null) {
        rec.put("gender", wGender.getWidgetValue());
    }
    if (wAge.getValue() != null && wAge.getValue() != "") {
        rec.put("age", wAge.getValue());
    }

    // Debug
    JsonUtil.debug("ClinicRegistration.submitForm() called with : " + JsonUtil.jsonify(rec));

    JsonUtil.debug("ClinicRegistration.submitForm() attempting add");
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        JsonUtil.debug("Try to build parameters");
        String[] params = { getModuleName(), JsonUtil.jsonify(rec) };
        JsonUtil.debug("Create requestbuilder for " + getModuleName() + ", " + JsonUtil.jsonify(rec));
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleAddMethod", params)));
        JsonUtil.debug("Entering try statement");
        try {
            JsonUtil.debug("Sending request");
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg(getModuleName(), _("Failed to add."));
                }

                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(getModuleName(), _("Added successfully."));
                            resetForm();
                        }
                    } else {
                        Util.showErrorMsg(getModuleName(), _("Failed to add."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg(getModuleName(), _("Failed to update."));
        }
    } else { // add clause GWT-RPC
        // Add
        service.ModuleAddMethod(getModuleName(), rec, new AsyncCallback<Integer>() {
            public void onSuccess(Integer result) {
                Util.showInfoMsg(getModuleName(), _("Added successfully."));
                resetForm();
            }

            public void onFailure(Throwable th) {
                Util.showErrorMsg(getModuleName(), _("Failed to add."));
            }
        });
    } // end add cause
}

From source file:org.freemedsoftware.gwt.client.screen.entry.SupportModuleEntry.java

License:Open Source License

protected void buildForm() {
    if (moduleName != null) {
        // Get XML file name from module
        final String interfaceUrl = Util.getUIBaseUrl() + "resources/interface/" + moduleName + ".module.xml";
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(interfaceUrl));
        try {/*from   w w w.  j  a  v  a 2  s . co m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        rawXml = response.getText();
                        xmlToForm(response.getText());
                    } else {
                        GWT.log("Error requesting " + interfaceUrl + ": " + response.getStatusText(), null);
                    }
                }

                public void onError(Request request, Throwable exception) {
                    GWT.log("Exception", exception);
                }
            });
        } catch (RequestException e) {
            GWT.log("RequestException", e);
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.MainScreen.java

License:Open Source License

public void setLoginUserInfo() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO stubbed mode goes here
        loginUserInfo.setText("Stubbed Mode user");
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = {};//from w w w . j a v a 2s  .c  o m
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.core.User.GetName", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Window.alert(ex.toString());
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        String userName = (String) JsonUtil.shoehornJson(response.getText(), "String");
                        loginUserInfo.setText(userName.trim());
                        CurrentState.assignDefaultUser(userName);
                    }
                }
            });
        } catch (RequestException e) {
            Window.alert(e.getMessage());
        }
    } else {

        // TODO normal mode code goes here
    }
}

From source file:org.freemedsoftware.gwt.client.screen.MainScreen.java

License:Open Source License

public void populateDefaultProvider() {
    if (CurrentState.getDefaultProvider().intValue() < 1) {
        if (Util.getProgramMode() == ProgramMode.STUBBED) {
            // Do gornicht.
        } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
            String[] params = {};
            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                    Util.getJsonRequest("org.freemedsoftware.api.UserInterface.GetCurrentProvider", params)));
            try {
                builder.sendRequest(null, new RequestCallback() {
                    public void onError(Request request, Throwable ex) {
                        CurrentState.getToaster().addItem("MainScreen",
                                _("Could not determine provider information."), Toaster.TOASTER_ERROR);
                    }/*from ww  w  .j  a va  2s.c om*/

                    public void onResponseReceived(Request request, Response response) {
                        if (200 == response.getStatusCode()) {
                            Integer r = (Integer) JsonUtil.shoehornJson(JSONParser.parse(response.getText()),
                                    "Integer");
                            if (r != null) {
                                JsonUtil.debug("MainScreen.populateDefaultProvider: found " + r.toString());
                                CurrentState.assignDefaultProvider(r);
                            } else {
                                JsonUtil.debug("MainScreen.populateDefaultProvider: found error");
                            }
                        } else {
                            CurrentState.getToaster().addItem("MainScreen",
                                    _("Could not determine provider information."), Toaster.TOASTER_ERROR);
                        }
                    }
                });
            } catch (RequestException e) {
                Util.showErrorMsg("MainScreen", _("Could not determine provider information."));
            }
        } else {
            // TODO: GWT-RPC support for this function
        }
    } else {
        JsonUtil.debug("MainScreen.populateDefaultProvider: already assigned");
    }
}