Advertisement
Guest User

Untitled

a guest
Jan 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. try
  2. {
  3. String data = "";
  4.  
  5. Order order = orderConnector.getOrder(orderId);
  6.  
  7. if (order.hasNote())
  8. {
  9. JSONArray jsonArray = new JSONArray(CommonMethods.getInstance().changeFormattedStringToJson(order.getNote()));
  10.  
  11. for (int i = 0; i < jsonArray.length(); i++)
  12. {
  13. JSONObject jsonObject = jsonArray.getJSONObject(i);
  14.  
  15. if (jsonObject.getString(MyConstants.LINE_ITEM_ID).equals(lineItemIDLocal))
  16. {
  17. jsonArray.remove(i);
  18. }
  19. }
  20. data = CommonMethods.getInstance().changeJsonToFormattedString(jsonArray.put(CommonMethods.getInstance().createJsonObject(itemIDLocal, lineItemIDLocal, myPrice, timeType, name)));
  21. }
  22. else
  23. {
  24. JSONArray jsonArray = new JSONArray();
  25. data = CommonMethods.getInstance().changeJsonToFormattedString(jsonArray.put(CommonMethods.getInstance().createJsonObject(itemIDLocal, lineItemIDLocal, myPrice, timeType, name)));
  26.  
  27. }
  28.  
  29. order.setNote(data);
  30.  
  31. try {
  32. orderConnector.updateOrder(order);
  33. } catch (RemoteException e) {
  34. e.printStackTrace();
  35. } catch (ClientException e) {
  36. e.printStackTrace();
  37. } catch (ServiceException e) {
  38. e.printStackTrace();
  39. } catch (BindingException e) {
  40. e.printStackTrace();
  41. } catch (NumberFormatException e) {
  42. e.printStackTrace();
  43. } catch (NullPointerException e) {
  44. e.printStackTrace();
  45. }
  46. }
  47. catch (RemoteException | ClientException | ServiceException | BindingException e)
  48. {
  49. e.printStackTrace();
  50. } catch (JSONException e) {
  51. e.printStackTrace();
  52. } catch (NumberFormatException e) {
  53. e.printStackTrace();
  54. } catch (NullPointerException e) {
  55. e.printStackTrace();
  56. }
  57.  
  58. return null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement