Search in sources :

Example 1 with AvailabilityException

use of de.metas.purchasecandidate.availability.AvailabilityException in project metasfresh-webui-api by metasfresh.

the class PurchaseRowsLoader method handleThrowableForAsyncAvailabilityCheck.

private void handleThrowableForAsyncAvailabilityCheck(@Nullable final Throwable throwable) {
    if (throwable == null) {
        return;
    }
    if (throwable instanceof AvailabilityException) {
        final AvailabilityException availabilityException = (AvailabilityException) throwable;
        final List<DocumentId> changedRowIds = new ArrayList<>();
        final Set<Entry<PurchaseCandidate, Throwable>> entrySet = availabilityException.getPurchaseCandidate2Throwable().entrySet();
        for (final Entry<PurchaseCandidate, Throwable> purchaseCandidate2throwable : entrySet) {
            final PurchaseRow purchaseRowToAugment = purchaseCandidate2purchaseRow.get(purchaseCandidate2throwable.getKey());
            final PurchaseRow availabilityResultRow = purchaseRowFactory.rowFromThrowableBuilder().parentRow(purchaseRowToAugment).throwable(purchaseCandidate2throwable.getValue()).build();
            purchaseRowToAugment.setAvailabilityInfoRows(ImmutableList.of(availabilityResultRow));
            changedRowIds.add(purchaseRowToAugment.getId());
        }
        notifyViewOfChanges(changedRowIds);
    } else {
    // TODO: display an error-message in the webui
    }
}
Also used : AvailabilityException(de.metas.purchasecandidate.availability.AvailabilityException) Entry(java.util.Map.Entry) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ArrayList(java.util.ArrayList) PurchaseCandidate(de.metas.purchasecandidate.PurchaseCandidate)

Aggregations

PurchaseCandidate (de.metas.purchasecandidate.PurchaseCandidate)1 AvailabilityException (de.metas.purchasecandidate.availability.AvailabilityException)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1