use of org.folio.rest.acq.model.finance.BudgetCollection in project mod-orders by folio-org.
the class MockServer method handleGetBudgetByFinanceId.
private void handleGetBudgetByFinanceId(RoutingContext ctx) {
logger.info("handleGetInvoiceDocumentById got: GET " + ctx.request().path());
String fundId = ctx.request().getParam("id");
JsonObject collection = getBudgetsByFundIds(Collections.singletonList(fundId));
BudgetCollection budgetCollection = collection.mapTo(BudgetCollection.class);
if (budgetCollection.getTotalRecords() > 0) {
Budget budget = budgetCollection.getBudgets().get(0);
JsonObject budgetJson = JsonObject.mapFrom(budget);
addServerRqRsData(HttpMethod.GET, CURRENT_BUDGET, budgetJson);
ctx.response().setStatusCode(200).putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON).end(budgetJson.encodePrettily());
} else {
ctx.response().setStatusCode(404).end();
}
}
use of org.folio.rest.acq.model.finance.BudgetCollection in project mod-orders by folio-org.
the class MockServer method getBudgetsByFundIds.
private JsonObject getBudgetsByFundIds(List<String> budgetByFundIds) {
Supplier<List<Budget>> getFromFile = () -> {
try {
return new JsonObject(getMockData(BUDGETS_PATH)).mapTo(BudgetCollection.class).getBudgets();
} catch (IOException e) {
return Collections.emptyList();
}
};
List<Budget> budgets = getMockEntries(BUDGETS, Budget.class).orElseGet(getFromFile);
if (!budgetByFundIds.isEmpty()) {
budgets.removeIf(item -> !budgetByFundIds.contains(item.getFundId()));
}
Object record = new BudgetCollection().withBudgets(budgets).withTotalRecords(budgets.size());
return JsonObject.mapFrom(record);
}
use of org.folio.rest.acq.model.finance.BudgetCollection in project mod-invoice by folio-org.
the class MockServer method handleGetBudgetByFundId.
private void handleGetBudgetByFundId(RoutingContext ctx) {
logger.info("handleGetInvoiceDocumentById got: GET " + ctx.request().path());
String fundId = ctx.request().getParam("id");
JsonObject collection = getBudgetsByFundIds(Collections.singletonList(fundId));
BudgetCollection budgetCollection = collection.mapTo(BudgetCollection.class);
if (fundId.equals(FUND_ID_WITH_NOT_ACTIVE_BUDGET)) {
ctx.response().setStatusCode(404).end();
} else if (budgetCollection.getTotalRecords() > 0) {
Budget budget = budgetCollection.getBudgets().get(0);
JsonObject budgetJson = JsonObject.mapFrom(budget);
addServerRqRsData(HttpMethod.GET, CURRENT_BUDGET, budgetJson);
ctx.response().setStatusCode(200).putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON).end(budgetJson.encodePrettily());
} else {
ctx.response().setStatusCode(404).end();
}
}
use of org.folio.rest.acq.model.finance.BudgetCollection in project mod-invoice by folio-org.
the class MockServer method getBudgetsByFundIds.
private JsonObject getBudgetsByFundIds(List<String> budgetByFundIds) {
Supplier<List<Budget>> getFromFile = () -> {
try {
return new JsonObject(getMockData(BUDGETS_PATH)).mapTo(BudgetCollection.class).getBudgets();
} catch (IOException e) {
return Collections.emptyList();
}
};
List<Budget> budgets = getMockEntries(BUDGETS, Budget.class).orElseGet(getFromFile);
if (!budgetByFundIds.isEmpty()) {
budgets.removeIf(item -> !budgetByFundIds.contains(item.getFundId()));
}
Object record = new BudgetCollection().withBudgets(budgets).withTotalRecords(budgets.size());
return JsonObject.mapFrom(record);
}
Aggregations