List of usage examples for com.google.gson JsonObject get
public JsonElement get(String memberName)
From source file:account.SalesRegisterDetailCardWise.java
private void jbtnViewActionPerformedRoutine() { try {/*from w ww. j ava 2 s . com*/ AccountAPI accountAPI = lb.getRetrofit().create(AccountAPI.class); if (ac_cd == null) { ac_cd = ""; } if (!jCheckBox1.isSelected()) { ac_cd = ""; } JsonObject call = accountAPI.CardWiseSalesDetailStatement(ac_cd).execute().body(); lb.addGlassPane(this); if (call != null) { JsonObject result = call; if (result.get("result").getAsInt() == 1) { JsonArray array = call.getAsJsonArray("data"); dtm.setRowCount(0); dtm.setRowCount(0); double basic_amt = 0.00, tax_amt = 0.00, net_amt = 0.00, buy_back_amt = 0.00, ins_amt = 0.00, bajaj = 0.00; double cash = 0.00, bank = 0.00, card = 0.00; String tax_name = ""; String buy_back_model = ""; String old_ref_no = ""; for (int i = 0; i < array.size(); i++) { if (!old_ref_no.equalsIgnoreCase("") && !old_ref_no .equalsIgnoreCase(array.get(i).getAsJsonObject().get("ref_no").getAsString())) { Vector row = new Vector(); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(basic_amt); row.add(lb.Convert2DecFmtForRs(tax_amt)); row.add(net_amt); row.add(tax_name); row.add(cash); row.add(bank); row.add(card); row.add(bajaj); row.add(buy_back_amt); row.add(buy_back_model); row.add(ins_amt); row.add(lb.Convert2DecFmtForRs( basic_amt + tax_amt - cash - bank - card - buy_back_amt + ins_amt - bajaj)); basic_amt = 0.00; dtm.addRow(row); } Vector row = new Vector(); row.add(array.get(i).getAsJsonObject().get("ref_no").getAsString()); if (basic_amt == 0.00) { row.add(array.get(i).getAsJsonObject().get("v_type").getAsString()); row.add(array.get(i).getAsJsonObject().get("inv_no").getAsInt()); row.add(lb.ConvertDateFormetForDisplay( array.get(i).getAsJsonObject().get("v_date").getAsString())); row.add((array.get(i).getAsJsonObject().get("fname") == null) ? "" : array.get(i).getAsJsonObject().get("fname").getAsString()); } else { row.add(""); row.add(""); row.add(""); row.add(""); } row.add(array.get(i).getAsJsonObject().get("SR_ALIAS").getAsString()); row.add(array.get(i).getAsJsonObject().get("SR_NAME").getAsString()); row.add(array.get(i).getAsJsonObject().get("IMEI_NO").getAsString()); row.add(array.get(i).getAsJsonObject().get("SERAIL_NO").getAsString()); row.add(array.get(i).getAsJsonObject().get("QTY").getAsInt()); row.add(array.get(i).getAsJsonObject().get("RATE").getAsDouble()); row.add(array.get(i).getAsJsonObject().get("AMT").getAsDouble()); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); dtm.addRow(row); basic_amt = array.get(i).getAsJsonObject().get("det_tot").getAsDouble(); tax_amt = array.get(i).getAsJsonObject().get("tax_amt").getAsDouble() + array.get(i).getAsJsonObject().get("add_tax_amt").getAsDouble(); net_amt = array.get(i).getAsJsonObject().get("net_amt").getAsDouble(); cash = array.get(i).getAsJsonObject().get("CASH_AMT").getAsDouble(); bank = array.get(i).getAsJsonObject().get("BANK_AMT").getAsDouble(); card = array.get(i).getAsJsonObject().get("CARD_AMT").getAsDouble(); tax_name = array.get(i).getAsJsonObject().get("tax_name").getAsString(); buy_back_model = array.get(i).getAsJsonObject().get("buy_back_model").getAsString(); buy_back_amt = array.get(i).getAsJsonObject().get("buy_back_amt").getAsDouble(); ins_amt = array.get(i).getAsJsonObject().get("ins_amt").getAsDouble(); bajaj = array.get(i).getAsJsonObject().get("bajaj_amt").getAsDouble(); old_ref_no = array.get(i).getAsJsonObject().get("ref_no").getAsString(); } Vector row = new Vector(); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(basic_amt); row.add(lb.Convert2DecFmtForRs(tax_amt)); row.add(net_amt); row.add(tax_name); row.add(cash); row.add(bank); row.add(card); row.add(bajaj); row.add(buy_back_amt); row.add(buy_back_model); row.add(ins_amt); row.add(lb.Convert2DecFmtForRs( basic_amt + tax_amt + ins_amt - cash - bank - card - buy_back_amt - bajaj)); basic_amt = 0.00; dtm.addRow(row); double tot_basic = 0.00, tot_tax = 0.00, tot_cash = 0.00, tot_bank = 0.00, tot_card = 0.00, tot_buyBack = 0.00, tot_deb = 0.00, tot_ins_amt = 0.00, tot_bajaj_amt = 0.00, tot_net_amt = 0.00; for (int i = 0; i < jTable1.getRowCount(); i++) { tot_basic += lb.isNumber2(jTable1.getValueAt(i, 12).toString()); tot_tax += lb.isNumber2(jTable1.getValueAt(i, 13).toString()); tot_net_amt += lb.isNumber2(jTable1.getValueAt(i, 14).toString()); tot_cash += lb.isNumber2(jTable1.getValueAt(i, 16).toString()); tot_card += lb.isNumber2(jTable1.getValueAt(i, 18).toString()); tot_bajaj_amt += lb.isNumber2(jTable1.getValueAt(i, 19).toString()); tot_buyBack += lb.isNumber2(jTable1.getValueAt(i, 20).toString()); tot_ins_amt += lb.isNumber2(jTable1.getValueAt(i, 22).toString()); tot_deb += lb.isNumber2(jTable1.getValueAt(i, 23).toString()); } row = new Vector(); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(""); row.add(lb.Convert2DecFmtForRs(tot_basic)); row.add(lb.Convert2DecFmtForRs(tot_tax)); row.add(lb.Convert2DecFmtForRs(tot_net_amt)); row.add(""); row.add(lb.Convert2DecFmtForRs(tot_cash)); row.add(lb.Convert2DecFmtForRs(tot_bank)); row.add(lb.Convert2DecFmtForRs(tot_card)); row.add(lb.Convert2DecFmtForRs(tot_bajaj_amt)); row.add(lb.Convert2DecFmtForRs(tot_buyBack)); row.add(""); row.add(lb.Convert2DecFmtForRs(tot_ins_amt)); row.add(lb.Convert2DecFmtForRs(tot_deb)); dtm.addRow(row); lb.setColumnSizeForTable(jTable1, jPanel1.getWidth()); lb.removeGlassPane(SalesRegisterDetailCardWise.this); } else { lb.removeGlassPane(SalesRegisterDetailCardWise.this); lb.showMessageDailog(call.get("Cause").getAsString()); } } } catch (IOException ex) { Logger.getLogger(SalesRegisterDetailCardWise.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveActionMessageFactoryImpl.java
License:Open Source License
@Override public ReceiveMessage createReceiveMessage(final JsonObject json) { final ReceiveMessage result = new ReceiveMessage(); result.setNativePayload(SlackPlatformEnum.SLACK, json); final String actionTs = json.get(ACTION_TS).getAsString(); final JsonObject userJsonObject = json.get(USER).getAsJsonObject(); final String userId = userJsonObject.get(ID).getAsString(); final String messageId = actionTs + "-" + userId; result.setMessageId(messageId);/*from w w w. j a v a 2 s .co m*/ handleSender(json, result); handleRecipient(json, result); if (json.has(ACTIONS)) { handleActions(json.get(ACTIONS).getAsJsonArray(), result); } return result; }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveActionMessageFactoryImpl.java
License:Open Source License
protected void handleRecipient(final JsonObject json, final ReceiveMessage result) { final Participant participant = new Participant(); participant.setPlatform(SlackPlatformEnum.SLACK); if (json.has(CHANNEL)) { final JsonObject channelJsonObject = json.get(CHANNEL).getAsJsonObject(); if (channelJsonObject.has(ID)) { final String channel = channelJsonObject.get(ID).getAsString(); participant.setId(channel);//from w ww . j a v a2 s . c o m } } result.setRecipient(participant); }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveActionMessageFactoryImpl.java
License:Open Source License
protected void handleSender(final JsonObject json, final ReceiveMessage result) { final Participant participant = new Participant(); participant.setPlatform(SlackPlatformEnum.SLACK); if (json.has(CHANNEL)) { final JsonObject channelJsonObject = json.get(CHANNEL).getAsJsonObject(); if (channelJsonObject.has(ID)) { final String channel = channelJsonObject.get(ID).getAsString(); participant.setId(channel);/*from w w w . j a va 2 s . c om*/ } } result.setSender(participant); }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveEventMessageFactoryImpl.java
License:Open Source License
@Override public ReceiveMessage createReceiveMessage(final JsonObject json) { final ReceiveMessage result = new ReceiveMessage(); result.setNativePayload(SlackPlatformEnum.SLACK, json); final String eventTs = json.get(EVENT_TS).getAsString(); final String username = json.get(USER).getAsString(); final String messageId = eventTs + "-" + username; result.setMessageId(messageId);/*from www . jav a2 s .c o m*/ handleSender(json, result); handleRecipient(json, result); if (json.has(TEXT)) { handleText(json.get(TEXT).getAsString(), result); } return result; }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveEventMessageFactoryImpl.java
License:Open Source License
protected void handleRecipient(final JsonObject json, final ReceiveMessage result) { final Participant participant = new Participant(); participant.setPlatform(SlackPlatformEnum.SLACK); final String channel = json.get(CHANNEL).getAsString(); participant.setId(channel);//from ww w . j a va 2s . c o m result.setRecipient(participant); }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceiveEventMessageFactoryImpl.java
License:Open Source License
protected void handleSender(final JsonObject json, final ReceiveMessage result) { final Participant participant = new Participant(); participant.setPlatform(SlackPlatformEnum.SLACK); final String channel = json.get(CHANNEL).getAsString(); participant.setId(channel);//w w w .j av a 2 s . c o m result.setSender(participant); }
From source file:ai.nitro.bot4j.integration.slack.receive.impl.SlackReceivePayloadFactoryImpl.java
License:Open Source License
@Override public PostbackReceivePayload createPostbackReceivePayload(final JsonObject actionJson) { final PostbackReceivePayload result = new PostbackReceivePayload(); result.setName(actionJson.get(NAME).getAsString()); final String serializedPayload = actionJson.get(VALUE).getAsString(); final PostbackPayload postbackPayload = postbackPayloadService.deserialize(serializedPayload); result.setPayload(postbackPayload.payload); return result; }
From source file:ai.nitro.bot4j.integration.slack.receive.webhook.impl.SlackEventWebhookImpl.java
License:Open Source License
protected void handleEvent(final JsonObject jsonReq, final HttpServletResponse res) { final JsonObject eventJsonObject = jsonReq.get(EVENT).getAsJsonObject(); if (!eventJsonObject.has(TYPE)) { LOG.warn("no type in event JSON"); } else if (!MESSAGE.equals(eventJsonObject.get(TYPE).getAsString())) { LOG.warn("no message in event JSON"); } else if (eventJsonObject.has(BOT_ID)) { LOG.info("ignoring bot message"); } else if (eventJsonObject.has(SUBTYPE) && BOT_MESSAGE.equals(eventJsonObject.get(SUBTYPE).getAsString())) { LOG.info("ignoring bot message"); } else {/*w w w .jav a 2 s. c om*/ slackReceiveHandler.handleEvent(eventJsonObject, (long) 0); } }
From source file:ai.nitro.bot4j.integration.slack.receive.webhook.impl.SlackEventWebhookImpl.java
License:Open Source License
protected String handleUrlVerification(final JsonObject jsonReq, final HttpServletResponse res) throws IOException { res.setContentType("application/x-www-form-urlencoded"); final JsonElement jsonElementChallenge = jsonReq.get(CHALLENGE); final String challenge = jsonElementChallenge.getAsString(); LOG.info("Responding challenge {}", challenge); return challenge; }