|
| 1 | +package com.intuit.developer.sampleapp.crud.entities.preferences; |
| 2 | + |
| 3 | +import java.text.ParseException; |
| 4 | +import java.util.List; |
| 5 | + |
| 6 | +import com.intuit.developer.sampleapp.crud.qbo.DataServiceFactory; |
| 7 | +import com.intuit.ipp.data.Preferences; |
| 8 | +import com.intuit.ipp.data.Error; |
| 9 | +import com.intuit.ipp.exception.FMSException; |
| 10 | +import com.intuit.ipp.services.DataService; |
| 11 | +import com.intuit.ipp.services.QueryResult; |
| 12 | +import com.intuit.ipp.util.Logger; |
| 13 | + |
| 14 | +/** |
| 15 | + * Demonstrates methods to query preferences data |
| 16 | + * 1. Query all records |
| 17 | + * |
| 18 | + * @author dderose |
| 19 | + * |
| 20 | + */ |
| 21 | +public class PreferencesQuery { |
| 22 | + |
| 23 | + private static final org.slf4j.Logger LOG = Logger.getLogger(); |
| 24 | + |
| 25 | + public static void main(String[] args) { |
| 26 | + try { |
| 27 | + queryPreferences(); |
| 28 | + } catch (Exception e) { |
| 29 | + LOG.error("Error during CRUD", e.getCause()); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + public static void queryPreferences() throws FMSException, ParseException { |
| 34 | + |
| 35 | + try { |
| 36 | + |
| 37 | + DataService service = DataServiceFactory.getDataService(); |
| 38 | + |
| 39 | + // get all preferences |
| 40 | + String sql = "select * from preferences"; |
| 41 | + QueryResult queryResult = service.executeQuery(sql); |
| 42 | + if (!queryResult.getEntities().isEmpty() && queryResult.getEntities().size() > 0) { |
| 43 | + Preferences preferences = (Preferences) queryResult.getEntities().get(0); |
| 44 | + LOG.info("Preferences -> SalesFormsPrefs - > DefaultCustomerMessage: " + preferences.getSalesFormsPrefs().getDefaultCustomerMessage()); |
| 45 | + } |
| 46 | + |
| 47 | + } catch (FMSException e) { |
| 48 | + List<Error> list = e.getErrorList(); |
| 49 | + list.forEach(error -> LOG.error("Error while calling executeQuery :: " + error.getMessage())); |
| 50 | + } |
| 51 | + |
| 52 | + } |
| 53 | +} |
0 commit comments