public void savePlateSearchAsSpot() { GWT.log("showSpot factual"); SpotHolder spotHolder = new SpotHolder(); spotHolder.setName(plateNameTextBox.getValue()); spotHolder.setCountryCode(countryTextBox.getValue()); spotHolder.setState(stateTextBox.getValue()); String color = getValue(colorsListBox); spotHolder.setColor(color); Long manufacturerId = getManufacturerId(); spotHolder.getManufacturerHolder().setId(manufacturerId); String vehicleType = getValue(vehicleTypeListBox); spotHolder.setVehicleType(vehicleType); spotHolder.setDescription(keywordsTextBox.getValue()); spotHolder.setSpotType(2); SaveSpotRequest saveSpotRequest = new SaveSpotRequest(); saveSpotRequest.setIgnoreUploads(true); saveSpotRequest.setSpotHolder(spotHolder); ApiServiceAsync myService = mywebapp.getApiServiceAsync(); myService.saveSpot( saveSpotRequest, new AsyncCallback() { public void onFailure(Throwable caught) { // callback.onFailure(caught); getMessagePanel().displayError("Could not save plate:" + caught.toString()); } public void onSuccess(Object result) { // callback.onSuccess(result); MobileResponse mobileResponse = (MobileResponse) result; if (mobileResponse.getStatus() == 1) { SpotHolder spotHolder1 = mobileResponse.getSpotHolder(); String token = MyWebApp.LEAVE_SPOT_MARK + spotHolder1.getId(); History.newItem(token); } else { getMessagePanel().displayErrors(mobileResponse.getErrorMessages()); } } }); }
public void performPlateSearch() { getMessagePanel().clear(); if (isEmpty(plateNameTextBox)) { getMessagePanel().displayError("Plate is required."); } if (isEmpty(countryTextBox.getTextBox())) { getMessagePanel().displayError("Country is required."); } if (isEmpty(stateTextBox.getTextBox())) { getMessagePanel().displayError("State is required."); } if (isEmpty(colorsListBox)) { getMessagePanel().displayError("Color is required."); } else { // getMessagePanel().displayError("Color is " + colorsListBox.getSelectedIndex()); } if (isEmpty(manufacturersListBox)) { getMessagePanel().displayError("Manufacturer is required."); } if (isEmpty(vehicleTypeListBox)) { getMessagePanel().displayError("Vehicle Type is required."); } if (getMessagePanel().isHaveMessages()) { return; } SearchParameters searchParameters = new SearchParameters(); searchParameters.setLicensePlate(true); searchParameters.setSpots(true); searchParameters.setPlateName(plateNameTextBox.getValue()); searchParameters.setKeywords(keywordsTextBox.getValue()); searchParameters.setCountryShortNameCode(countryTextBox.getValue()); searchParameters.setState(stateTextBox.getValue()); { String val = getValue(colorsListBox); searchParameters.setColor(val); } Long manufacturerId = getManufacturerId(); searchParameters.setManufacturerId(manufacturerId); { String val = getValue(vehicleTypeListBox); searchParameters.setVehicleType(val); } searchParameters.setMax(20); ApiServiceAsync myService = mywebapp.getApiServiceAsync(); myService.search( searchParameters, new AsyncCallback() { DataOperationDialog fetchLocalSpotsDialog = new DataOperationDialog("Searching Plates."); public void onFailure(Throwable caught) { fetchLocalSpotsDialog.hide(); getMessagePanel().displayError(caught.getMessage()); } public void onSuccess(Object result) { fetchLocalSpotsDialog.hide(); MobileResponse mobileResponse = (MobileResponse) result; if (mobileResponse.getStatus() == 1) { // if no plates were found, let's just go to the new plate form if (mobileResponse.getLocationResults().isEmpty()) { savePlateSearchAsSpot(); } else { displayLicensePlates(mobileResponse.getLocationResults(), 1); } } else { getMessagePanel().displayErrors(mobileResponse.getErrorMessages()); } } }); }