@Override public Result downloadAndParse() { Result result = officeSheetPopulator.downloadAndParse(); if (result.isSuccess()) result = clientSheetPopulator.downloadAndParse(); if (result.isSuccess()) result = extrasSheetPopulator.downloadAndParse(); if (result.isSuccess()) { try { restClient.createAuthToken(); content = restClient.get("savingsaccounts?limit=-1"); Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonObject obj = parser.parse(content).getAsJsonObject(); JsonArray array = obj.getAsJsonArray("pageItems"); Iterator<JsonElement> iterator = array.iterator(); while (iterator.hasNext()) { JsonElement json = iterator.next(); CompactSavingsAccount savingsAccount = gson.fromJson(json, CompactSavingsAccount.class); if (savingsAccount.isActive()) savings.add(savingsAccount); } } catch (Exception e) { result.addError(e.getMessage()); logger.error(e.getMessage()); } } return result; }
@Override public Result populate(Workbook workbook) { Sheet savingsTransactionSheet = workbook.createSheet("SavingsTransaction"); setLayout(savingsTransactionSheet); Result result = officeSheetPopulator.populate(workbook); if (result.isSuccess()) result = clientSheetPopulator.populate(workbook); if (result.isSuccess()) result = extrasSheetPopulator.populate(workbook); if (result.isSuccess()) result = populateLoansTable(savingsTransactionSheet); if (result.isSuccess()) result = setRules(savingsTransactionSheet); setDefaults(savingsTransactionSheet); return result; }