use of de.metas.purchasecandidate.SalesOrderLines in project metasfresh-webui-api by metasfresh.
the class SalesOrder2PurchaseViewFactory method createView.
@Override
public PurchaseView createView(final CreateViewRequest request) {
final Set<Integer> salesOrderLineIds = request.getFilterOnlyIds();
Check.assumeNotEmpty(salesOrderLineIds, "salesOrderLineIds is not empty");
final ViewId viewId = ViewId.random(WINDOW_ID);
final SalesOrderLines saleOrderLines = SalesOrderLines.builder().salesOrderLineIds(salesOrderLineIds).purchaseCandidateRepository(purchaseCandidatesRepo).build();
final PurchaseRowsLoader rowsLoader = PurchaseRowsLoader.builder().salesOrderLines(saleOrderLines).viewSupplier(// needed for async stuff
() -> this.getByIdOrNull(viewId)).purchaseRowFactory(purchaseRowFactory).build();
final PurchaseRowsSupplier rowsSupplier = () -> {
final List<PurchaseRow> loadResult = rowsLoader.load();
if (makeAsynchronousAvailiabilityCheck()) {
rowsLoader.createAndAddAvailabilityResultRowsAsync();
} else {
rowsLoader.createAndAddAvailabilityResultRows();
}
return loadResult;
};
final PurchaseView view = PurchaseView.builder().viewId(viewId).rowsSupplier(rowsSupplier).additionalRelatedProcessDescriptor(createProcessDescriptor(WEBUI_SalesOrder_Apply_Availability_Row.class)).build();
return view;
}
Aggregations