use of org.folio.orders.utils.HelperUtils.DEFAULT_POLINE_LIMIT in project mod-orders by folio-org.
the class MockServer method buildPoLineCollection.
private PoLineCollection buildPoLineCollection(String tenant, JsonArray lines, String poId) {
PoLineCollection result = new PoLineCollection();
if (lines == null || lines.isEmpty()) {
result.setTotalRecords(0);
} else {
// Transform composite PO Lines to storage representation
List<PoLine> poLines = lines.stream().map(JsonObject::mapFrom).map(line -> {
replaceObjectsByIds(line, ALERTS, REPORTING_CODES);
return line.mapTo(PoLine.class);
}).map(line -> line.withPurchaseOrderId(StringUtils.isNotEmpty(poId) ? poId : UUID.randomUUID().toString())).collect(Collectors.toList());
// Set PO Line number if empty
for (PoLine line : poLines) {
if (StringUtils.isEmpty(line.getPoLineNumber())) {
line.setPoLineNumber(PO_NUMBER_VALUE + "-1");
}
}
result.setPoLines(poLines);
if (EMPTY_CONFIG_TENANT.equals(tenant)) {
result.setTotalRecords(Integer.parseInt(DEFAULT_POLINE_LIMIT));
} else {
result.setTotalRecords(lines.size());
}
}
return result;
}
Aggregations