Example usage for com.google.gwt.http.client RequestBuilder sendRequest

List of usage examples for com.google.gwt.http.client RequestBuilder sendRequest

Introduction

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

Prototype

public Request sendRequest(String requestData, RequestCallback callback) throws RequestException 

Source Link

Document

Sends an HTTP request based on the current builder configuration with the specified data and callback.

Usage

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

License:Open Source License

public void populate() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: handle stubbed
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        toolTable.showloading(true);// ww w  . ja  v a  2s .com
        String[] params = {};
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Tools.GetTools", 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) {
                            toolTable.loadData(result);
                        } else {
                            toolTable.showloading(false);
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            GWT.log("Exception", e);
        }
    } else {
        // TODO: Make this work with GWT-RPC
    }
}

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

License:Open Source License

protected void createPatient(Integer clinicRegistrationId) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(clinicRegistrationId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.ClinicRegistration.createPatient", params)));
        try {// ww w .j av  a 2s .c  o m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showInfoMsg("TriageScreen", _("Failed to create new patient record."));
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            String raw = (String) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "String");
                            Integer r = null;
                            try {
                                r = Integer.parseInt(raw);
                            } catch (Exception ex) {
                                JsonUtil.debug("Unable to parse returned patient id");
                            }
                            if (r != null) {
                                Util.showInfoMsg("TriageScreen", _("New patient record created."));
                                loadVitalsScreen(r);
                            } else {
                                Util.showInfoMsg("TriageScreen", _("Failed to create new patient record."));
                            }
                        } else {
                            Util.showInfoMsg("TriageScreen", _("Failed to create new patient record."));
                        }
                    }
                }
            });
        } catch (RequestException e) {
            JsonUtil.debug(e.getMessage());
            Util.showInfoMsg("TriageScreen", _("Failed to create new patient record."));
        }
    } else {
        JsonUtil.debug("NOT IMPLEMENTED YET");
    }
}

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

License:Open Source License

/**
 * Called to request migrating a clinicregistration table entry to being
 * associated with an existing patient table entry. Is completely backend
 * functional, has no UI pieces of any import.
 * // ww  w.j a  v  a  2 s .  c om
 * @param clinicRegistrationId
 * @param patientId
 */
protected void migrateToPatient(Integer clinicRegistrationId, Integer patientId) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(clinicRegistrationId), JsonUtil.jsonify(patientId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.ClinicRegistration.migrateToPatient", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            Boolean r = (Boolean) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean");
                            if (r != null) {
                            }
                        } else {
                        }

                        // Force refresh after migrate is complete.
                        loadData();
                    }
                }
            });
        } catch (RequestException e) {
            JsonUtil.debug(e.getMessage());
        }
    } else {
        JsonUtil.debug("NOT IMPLEMENTED YET");
    }
}

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

License:Open Source License

/**
 * Load table entries and reset form./*www .  ja va 2  s .c o  m*/
 */
@SuppressWarnings("unchecked")
protected void loadData() {
    flexTable.setVisible(false);
    mainHorizontalPanel.setVisible(true);
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
        results.add(new HashMap<String, String>() {
            private static final long serialVersionUID = -208742530745599186L;
            {
                // FIXME: need test values
                put("id", "1");
                put("uffdate", "2008-08-10");
                put("ufffilename", "testFile1.pdf");
            }
        });
        results.add(new HashMap<String, String>() {
            private static final long serialVersionUID = -2068691951700967021L;
            {
                // FIXME: need test values
                put("id", "2");
                put("uffdate", "2008-08-25");
                put("ufffilename", "testFile2.pdf");
            }
        });
        wTriagePendingList.loadData(results.toArray((HashMap<String, String>[]) new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        wTriagePendingList.showloading(true);
        String[] params = {};
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.module.ClinicRegistration.GetAll", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    wTriagePendingList.showloading(false);
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                store = r;
                                wTriagePendingList.loadData(r);
                            }
                        } else {
                            wTriagePendingList.showloading(false);
                        }
                    }
                }
            });
        } catch (RequestException e) {
            JsonUtil.debug(e.getMessage());
            wTriagePendingList.showloading(false);
        }
    } else {
        JsonUtil.debug("NOT IMPLEMENTED YET");
        /*
         * getDocumentsProxy().GetAll( new AsyncCallback<HashMap<String,
         * String>[]>() { public void onSuccess(HashMap<String, String>[]
         * res) { store = res; wTriagePendingList.loadData(res); }
         * 
         * public void onFailure(Throwable t) { GWT.log("Exception", t); }
         * });
         */
    }
}

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

License:Open Source License

public UnfiledDocuments() {
    super(moduleName);
    VerticalPanel parentVp = new VerticalPanel();
    parentVp.setSize("10o%", "100%");
    initWidget(parentVp);//from ww w .  j  av a 2 s . co  m
    mainHorizontalPanel = new HorizontalPanel();
    parentVp.add(mainHorizontalPanel);

    mainHorizontalPanel.setSize("100%", "100%");

    batchSplitVp = new VerticalPanel();
    batchSplitVp.setSize("100%", "100%");
    batchSplitVp.setVisible(false);
    parentVp.add(batchSplitVp);
    final VerticalPanel verticalPanel = new VerticalPanel();
    mainHorizontalPanel.add(verticalPanel);
    verticalPanel.setSize("100%", "100%");

    wDocuments = new CustomTable();
    verticalPanel.add(wDocuments);
    wDocuments.setIndexName("id");
    wDocuments.addColumn(_("Date"), "uffdate");
    wDocuments.addColumn(_("Filename"), "ufffilename");
    wDocuments.addColumn(_("Action"), "action");
    wDocuments.setTableWidgetColumnSetInterface(new TableWidgetColumnSetInterface() {
        public Widget setColumn(String columnName, HashMap<String, String> data) {
            // Render only action column, otherwise skip renderer
            if (columnName.compareToIgnoreCase("action") != 0) {
                return null;
            }
            final CustomActionBar actionBar = new CustomActionBar(data);
            actionBar.applyPermissions(false, false, true, false, false);
            actionBar.setHandleCustomAction(new HandleCustomAction() {
                @Override
                public void handleAction(int id, HashMap<String, String> data, int action) {
                    if (action == HandleCustomAction.DELETE) {
                        try {
                            String[] params = { "" + id };
                            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                                    URL.encode(Util.getJsonRequest(
                                            "org.freemedsoftware.module.UnfiledDocuments.del", 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 (Util.checkValidSessionResponse(response.getText())) {
                                            if (200 == response.getStatusCode()) {
                                                try {
                                                    Boolean result = (Boolean) JsonUtil.shoehornJson(
                                                            JSONParser.parseStrict(response.getText()),
                                                            "Boolean");
                                                    if (result) {
                                                        Util.showInfoMsg("UnfiledDocuments",
                                                                _("Document successfully deleted."));
                                                        loadData();
                                                    }
                                                } catch (Exception e) {
                                                    Util.showErrorMsg("UnfiledDocuments",
                                                            _("Document failed to delete."));
                                                }
                                            } else {
                                                Util.showErrorMsg("UnfiledDocuments",
                                                        _("Document failed to delete."));
                                            }
                                        }
                                    }
                                });
                            } catch (RequestException e) {
                                Util.showErrorMsg("UnfiledDocuments", _("Document failed to delete."));
                            }
                        } catch (Exception e) {
                            Util.showErrorMsg("UnfiledDocuments", _("Document failed to delete"));
                        }
                    }
                }
            });

            // Push value back to table
            return actionBar;
        }
    });
    wDocuments.setTableRowClickHandler(new TableRowClickHandler() {
        @Override
        public void handleRowClick(HashMap<String, String> data, int col) {
            if (col == 0 || col == 1) {
                // Import current id
                try {
                    currentId = Integer.parseInt(data.get("id"));
                } catch (Exception ex) {
                    GWT.log("Exception", ex);
                } finally {
                    if (canWrite) {
                        // Populate
                        String pDate = data.get("uffdate");
                        Calendar thisCal = new GregorianCalendar();
                        thisCal.set(Calendar.YEAR, Integer.parseInt(pDate.substring(0, 4)));
                        thisCal.set(Calendar.MONTH, Integer.parseInt(pDate.substring(5, 6)) - 1);
                        thisCal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(pDate.substring(8, 9)));
                        wDate.setValue(thisCal.getTime());

                        // Show the form
                        flexTable.setVisible(true);
                        horizontalPanel.setVisible(true);
                    }
                    if (canRead) {
                        // Show the image in the viewer
                        djvuViewer.setInternalId(currentId);
                        /*
                        try {
                           djvuViewer.loadPage(1);
                        } catch (Exception ex) {
                           JsonUtil.debug(ex.toString());
                        }
                        djvuViewer.setVisible(true);
                        */
                    }
                }
            }
        }
    });
    wDocuments.setWidth("100%");

    flexTable = new FlexTable();
    verticalPanel.add(flexTable);
    flexTable.setWidth("100%");
    flexTable.setVisible(false);

    final Label dateLabel = new Label(_("Date") + " : ");
    flexTable.setWidget(0, 0, dateLabel);

    wDate = new CustomDatePicker();
    wDate.setValue(new Date());
    flexTable.setWidget(0, 1, wDate);

    final Label patientLabel = new Label(_("Patient") + " : ");
    flexTable.setWidget(1, 0, patientLabel);

    wPatient = new PatientWidget();
    flexTable.setWidget(1, 1, wPatient);

    final Label providerLabel = new Label(_("Provider") + " : ");
    flexTable.setWidget(2, 0, providerLabel);

    wProvider = new SupportModuleWidget();
    wProvider.setModuleName("ProviderModule");
    flexTable.setWidget(2, 1, wProvider);

    final Label noteLabel = new Label(_("Note") + " : ");
    flexTable.setWidget(3, 0, noteLabel);

    wNote = new TextBox();
    flexTable.setWidget(3, 1, wNote);
    wNote.setWidth("100%");

    final Label notifyLabel = new Label(_("Notify") + " : ");
    flexTable.setWidget(4, 0, notifyLabel);

    users = new UserMultipleChoiceWidget();
    flexTable.setWidget(4, 1, users);
    //wNote.setWidth("100%");

    final Label categoryLabel = new Label(_("Category") + " : ");
    flexTable.setWidget(5, 0, categoryLabel);

    wCategory = new SupportModuleWidget();
    wCategory.setModuleName("DocumentCategory");
    flexTable.setWidget(5, 1, wCategory);

    final Label faxNumberLabel = new Label(_("Fax Confirmation Number") + " : ");
    flexTable.setWidget(6, 0, faxNumberLabel);

    faxConfirmationNumber = new TextBox();
    flexTable.setWidget(6, 1, faxConfirmationNumber);

    final Label rotateLabel = new Label(_("Rotate") + " : ");
    flexTable.setWidget(7, 0, rotateLabel);

    wRotate = new ListBox();
    flexTable.setWidget(7, 1, wRotate);
    wRotate.addItem(_("No rotation"), "0");
    wRotate.addItem(_("Rotate left"), "270");
    wRotate.addItem(_("Rotate right"), "90");
    wRotate.addItem(_("Flip"), "180");
    wRotate.setVisibleItemCount(1);

    cbRemoveFirstPage = new CheckBox(_("Remove First Page"));
    flexTable.setWidget(8, 0, cbRemoveFirstPage);
    horizontalPanel = new HorizontalPanel();
    horizontalPanel.setVisible(false);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    verticalPanel.add(horizontalPanel);
    horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);

    final PushButton sendToProviderButton = new PushButton();
    sendToProviderButton.setStylePrimaryName("freemed-PushButton");
    sendToProviderButton.setHTML(_("Send to Provider"));
    sendToProviderButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (validateForm()) {
                sendToProvider();
            }
        }
    });
    horizontalPanel.add(sendToProviderButton);

    final PushButton fileDirectlyButton = new PushButton();
    fileDirectlyButton.setHTML(_("File Directly"));
    fileDirectlyButton.setStylePrimaryName("freemed-PushButton");
    fileDirectlyButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (validateForm()) {
                fileDirectly();
            }
        }
    });
    horizontalPanel.add(fileDirectlyButton);

    final PushButton splitBatchButton = new PushButton();
    splitBatchButton.setHTML(_("Split Batch"));
    splitBatchButton.setStylePrimaryName("freemed-PushButton");
    splitBatchButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (djvuViewer.getPageCount() > 1) {

                final DocumentThumbnailsWidget dtw = new DocumentThumbnailsWidget(djvuViewer,
                        new CustomRequestCallback() {
                            @Override
                            public void onError() {

                            }

                            @Override
                            public void jsonifiedData(Object data) {
                                if (data instanceof Integer) {
                                    loadData();
                                } else if (data instanceof Integer[]) {
                                    splitBatch((Integer[]) data);
                                }

                            }
                        });
                batchSplitVp.add(dtw);
                mainHorizontalPanel.setVisible(false);
                batchSplitVp.setVisible(true);

            } else if (djvuViewer.getPageCount() == 1) {
                Window.alert(_("Current document has only one page."));
            }
        }
    });
    horizontalPanel.add(splitBatchButton);
    djvuViewer = new DjvuViewer();
    djvuViewer.setType(DjvuViewer.UNFILED_DOCUMENTS);
    mainHorizontalPanel.add(djvuViewer);
    djvuViewer.setVisible(false);
    djvuViewer.setSize("100%", "100%");

    // Last thing is to initialize, otherwise we're going to get some
    // NullPointerException errors
    if (canRead)
        loadData();
}

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

License:Open Source License

protected void fileDirectly() {
    HashMap<String, String> p = new HashMap<String, String>();
    p.put((String) "id", (String) currentId.toString());
    p.put((String) "patient", (String) wPatient.getValue().toString());
    p.put((String) "category", (String) wCategory.getValue().toString());
    p.put((String) "physician", (String) wProvider.getValue().toString());
    if (cbRemoveFirstPage.getValue())
        p.put((String) "withoutfirstpage", (String) "1");
    else//from   www .  j a v a 2s  .c o  m
        p.put((String) "withoutfirstpage", (String) "");
    p.put((String) "filedirectly", (String) "1");
    p.put((String) "note", (String) wNote.getText());
    p.put((String) "faxback", (String) faxConfirmationNumber.getText());
    p.put((String) "flip", (String) wRotate.getValue(wRotate.getSelectedIndex()));
    if (users.getCommaSeparatedValues() != null)
        p.put((String) "notify", users.getCommaSeparatedValues());
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        CurrentState.getToaster().addItem("UnfiledDocuments", "Processed unfiled document.",
                Toaster.TOASTER_INFO);
        loadData();
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { "UnfiledDocuments", JsonUtil.jsonify(p) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleModifyMethod", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    CurrentState.getToaster().addItem("UnfiledDocuments", _("Failed to file document."),
                            Toaster.TOASTER_ERROR);
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            Integer r = (Integer) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer");
                            if (r != null) {
                                Util.showInfoMsg("UnfiledDocuments", _("Processed unfiled document."));
                                loadData();
                            }
                        } else {
                            Util.showErrorMsg("UnfiledDocuments", _("Failed to file document."));
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("UnfiledDocuments", _("Failed to file document."));
        }
    } else {
        getModuleProxy().ModuleModifyMethod("UnfiledDocuments", p, new AsyncCallback<Integer>() {
            public void onSuccess(Integer o) {
                Util.showInfoMsg("UnfiledDocuments", _("Processed unfiled document."));
                loadData();
            }

            public void onFailure(Throwable t) {
                Util.showErrorMsg("UnfiledDocuments", _("Failed to file document."));
                GWT.log("Exception", t);
            }
        });
    }
}

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

License:Open Source License

/**
 * Load table entries and reset form.//from   w ww  .j a  va2s .c o m
 */
@SuppressWarnings("unchecked")
protected void loadData() {
    batchSplitVp.setVisible(false);
    batchSplitVp.clear();
    djvuViewer.setVisible(false);
    flexTable.setVisible(false);
    horizontalPanel.setVisible(false);
    mainHorizontalPanel.setVisible(true);
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
        {
            HashMap<String, String> item = new HashMap<String, String>();
            item.put("id", "1");
            item.put("uffdate", "2008-08-10");
            item.put("ufffilename", "testFile1.pdf");
            results.add(item);
        }
        {
            HashMap<String, String> item = new HashMap<String, String>();
            item.put("id", "2");
            item.put("uffdate", "2008-08-25");
            item.put("ufffilename", "testFile2.pdf");
            results.add(item);
        }
        wDocuments.loadData(results.toArray((HashMap<String, String>[]) new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        wDocuments.showloading(true);
        String[] params = {};
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.UnfiledDocuments.GetAll", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                store = r;
                                wDocuments.loadData(r);
                            }
                        } else {
                            wDocuments.showloading(false);
                        }
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        getDocumentsProxy().GetAll(new AsyncCallback<HashMap<String, String>[]>() {
            public void onSuccess(HashMap<String, String>[] res) {
                store = res;
                wDocuments.loadData(res);
            }

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

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

License:Open Source License

protected void sendToProvider() {
    HashMap<String, String> p = new HashMap<String, String>();
    p.put((String) "id", (String) currentId.toString());
    p.put((String) "patient", (String) wPatient.getValue().toString());
    p.put((String) "category", (String) "");
    p.put((String) "physician", (String) wProvider.getValue().toString());
    if (cbRemoveFirstPage.getValue())
        p.put((String) "withoutfirstpage", (String) "1");
    else//from  w  w  w  . j  a  v  a 2 s .  co  m
        p.put((String) "withoutfirstpage", (String) "");
    p.put((String) "filedirectly", (String) "0");
    p.put((String) "note", (String) wNote.getText());
    p.put((String) "faxback", (String) faxConfirmationNumber.getText());
    p.put((String) "flip", (String) wRotate.getValue(wRotate.getSelectedIndex()));
    if (users.getCommaSeparatedValues() != null)
        p.put((String) "notify", users.getCommaSeparatedValues());
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        CurrentState.getToaster().addItem("UnfiledDocuments", "Processed unfiled document.",
                Toaster.TOASTER_INFO);
        loadData();
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { "UnfiledDocuments", JsonUtil.jsonify(p) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleModifyMethod", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("UnfiledDocuments", _("Failed to send document to provider."));
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            Integer r = (Integer) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer");
                            if (r != null) {
                                Util.showInfoMsg("UnfiledDocuments", _("Sent to provider."));
                            }
                        } else {
                            Util.showErrorMsg("UnfiledDocuments", _("Failed to send document to provider."));
                        }
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("UnfiledDocuments", _("Failed to send document to provider."));
        }
    } else {
        getModuleProxy().ModuleModifyMethod("UnfiledDocuments", p, new AsyncCallback<Integer>() {
            public void onSuccess(Integer o) {
                Util.showInfoMsg("UnfiledDocuments", _("Sent to provider."));
            }

            public void onFailure(Throwable t) {
                Util.showErrorMsg("UnfiledDocuments", _("Failed to send document to provider."));
            }
        });
    }
}

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

License:Open Source License

public void splitBatch(Integer[] pageNos) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { currentId.toString(), JsonUtil.jsonify(pageNos) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.module.UnfiledDocuments.batchSplit", params)));
        try {//from   w  ww  .  j av a2 s  . c  o m
            builder.sendRequest(null, new RequestCallback() {
                public void onError(com.google.gwt.http.client.Request request, Throwable ex) {
                    Util.showErrorMsg("UnfiledDocuments", _("Document failed to split."));
                }

                public void onResponseReceived(com.google.gwt.http.client.Request request,
                        com.google.gwt.http.client.Response response) {
                    if (200 == response.getStatusCode()) {
                        Boolean r = (Boolean) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()),
                                "Boolean");
                        if (r != null && r) {
                            Util.showInfoMsg("UnfiledDocuments", _("Document successfully split."));
                            loadData();
                        } else {
                            Util.showErrorMsg("UnfiledDocuments", _("Document failed to split."));
                        }
                    } else {
                        Util.showErrorMsg("UnfiledDocuments", _("Document failed to split."));
                        JsonUtil.debug(response.toString());
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("UnfiledDocuments", _("Document failed to split."));
            JsonUtil.debug(e.toString());
        }

    } else {

    }
}

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

License:Open Source License

/**
 * Load table entries and reset form.//from  ww  w . ja va  2  s .  c  om
 */
@SuppressWarnings("unchecked")
protected void loadData() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        List<HashMap<String, String>> results = new ArrayList<HashMap<String, String>>();
        {
            HashMap<String, String> item = new HashMap<String, String>();
            item.put("id", "1");
            item.put("urfdate_mdy", "2008-08-10");
            item.put("patient", "abc III, def");
            item.put("urfnote", "test note 123.");
            results.add(item);
        }
        {
            HashMap<String, String> item = new HashMap<String, String>();
            item.put("id", "2");
            item.put("urfdate_mdy", "2008-08-10");
            item.put("patient", "xyz III, uvw");
            item.put("urfnote", "Test note xyz.");
            results.add(item);
        }
        wDocuments.loadData(results.toArray((HashMap<String, String>[]) new HashMap<?, ?>[0]));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        wDocuments.showloading(true);
        String[] params = {};
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.UnreadDocuments.GetAll", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                store = r;
                                wDocuments.loadData(r);
                            }
                        } else {
                            wDocuments.showloading(false);
                        }
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        // TODO GWT STUFF
    }
}