|
| 1 | +package com.intuit.developer.sampleapp.crud.entities.reimbursecharge; |
| 2 | + |
| 3 | +import com.intuit.developer.sampleapp.crud.helper.RefundReceiptHelper; |
| 4 | +import com.intuit.developer.sampleapp.crud.qbo.DataServiceFactory; |
| 5 | +import com.intuit.ipp.data.Error; |
| 6 | +import com.intuit.ipp.data.RefundReceipt; |
| 7 | +import com.intuit.ipp.exception.FMSException; |
| 8 | +import com.intuit.ipp.services.DataService; |
| 9 | +import com.intuit.ipp.services.QueryResult; |
| 10 | +import com.intuit.ipp.util.Logger; |
| 11 | + |
| 12 | +import java.text.ParseException; |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +/** |
| 16 | + * Demonstrates methods to query refundreceipt data |
| 17 | + * 1. Query all records |
| 18 | + * 2. Query by id, note we'll add the entity first and then query |
| 19 | + * |
| 20 | + * @author dderose |
| 21 | + * |
| 22 | + */ |
| 23 | +public class ReimburseChargeQuery { |
| 24 | + |
| 25 | + private static final org.slf4j.Logger LOG = Logger.getLogger(); |
| 26 | + |
| 27 | + public static void main(String[] args) { |
| 28 | + try { |
| 29 | + queryReimburseCharge(); |
| 30 | + } catch (Exception e) { |
| 31 | + LOG.error("Error during CRUD", e.getCause()); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + public static void queryReimburseCharge() throws FMSException, ParseException { |
| 36 | + try { |
| 37 | + DataService service = DataServiceFactory.getDataService(); |
| 38 | + |
| 39 | + // get all reimbursecharge |
| 40 | + String sql = "Select * from ReimburseCharge"; |
| 41 | + QueryResult queryResult = service.executeQuery(sql); |
| 42 | + int count = queryResult.getEntities().size(); |
| 43 | + |
| 44 | + LOG.info("Total number of refundreceipts: " + count); |
| 45 | + |
| 46 | + // get reimbursecharge based on HasBeenInvoiced |
| 47 | + sql = "Select * from ReimburseCharge Where HasBeenInvoiced = false"; |
| 48 | + queryResult = service.executeQuery(sql); |
| 49 | + count = queryResult.getEntities().size(); |
| 50 | + LOG.info("There are " + count + " Reimburse Charges where HasBeenInvoiced = false"); |
| 51 | + } catch (FMSException e) { |
| 52 | + List<Error> list = e.getErrorList(); |
| 53 | + list.forEach(error -> LOG.error("Error while calling executeQuery :: " + error.getMessage())); |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments