Search in sources :

Example 1 with AvailabilityMultiResult

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

the class PurchaseRowsLoader method handleResultForAsyncAvailabilityCheck_Success.

private void handleResultForAsyncAvailabilityCheck_Success(final PurchaseRowsList rows, final AvailabilityMultiResult availabilityResults) {
    final List<DocumentId> changedRowIds = new ArrayList<>();
    for (final TrackingId trackingId : availabilityResults.getTrackingIds()) {
        final PurchaseRow lineRow = rows.getPurchaseRowByTrackingId(trackingId);
        if (lineRow == null) {
            logger.warn("No row found for {}. Skip updating the row with availability results.", trackingId);
            continue;
        }
        final ImmutableList<PurchaseRow> availabilityResultRows = availabilityResults.getByTrackingId(trackingId).stream().map(availabilityResult -> purchaseRowFactory.availabilityDetailSuccessBuilder().lineRow(lineRow).availabilityResult(availabilityResult).build()).collect(ImmutableList.toImmutableList());
        lineRow.setAvailabilityInfoRows(availabilityResultRows);
        changedRowIds.add(rows.getTopLevelDocumentIdByTrackingId(trackingId, lineRow.getId()));
    }
    notifyViewOfChanges(changedRowIds);
}
Also used : LogManager(de.metas.logging.LogManager) Getter(lombok.Getter) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Env(org.compiere.util.Env) AvailabilityException(de.metas.purchasecandidate.availability.AvailabilityException) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) AvailabilityMultiResult(de.metas.purchasecandidate.availability.AvailabilityMultiResult) ImmutableList(com.google.common.collect.ImmutableList) IView(de.metas.ui.web.view.IView) ISysConfigBL(org.adempiere.service.ISysConfigBL) PurchaseDemandWithCandidates(de.metas.purchasecandidate.PurchaseDemandWithCandidates) CoalesceUtil(de.metas.util.lang.CoalesceUtil) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) PurchaseDemand(de.metas.purchasecandidate.PurchaseDemand) Properties(java.util.Properties) Logger(org.slf4j.Logger) AvailabilityCheckService(de.metas.purchasecandidate.availability.AvailabilityCheckService) ImmutableMap(com.google.common.collect.ImmutableMap) NonNull(lombok.NonNull) PurchaseCandidatesAvailabilityRequest(de.metas.purchasecandidate.availability.PurchaseCandidatesAvailabilityRequest) TrackingId(de.metas.vendor.gateway.api.availability.TrackingId) Services(de.metas.util.Services) List(java.util.List) Builder(lombok.Builder) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) VisibleForTesting(com.google.common.annotations.VisibleForTesting) PurchaseCandidatesGroup(de.metas.purchasecandidate.PurchaseCandidatesGroup) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ArrayList(java.util.ArrayList) TrackingId(de.metas.vendor.gateway.api.availability.TrackingId)

Example 2 with AvailabilityMultiResult

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

the class PurchaseRowsLoader method createAndAddAvailabilityResultRows.

@VisibleForTesting
void createAndAddAvailabilityResultRows(final PurchaseRowsList rows) {
    try {
        final AvailabilityMultiResult availabilityCheckResult = availabilityCheckService.checkAvailability(createAvailabilityRequest(rows));
        handleResultForAsyncAvailabilityCheck_Success(rows, availabilityCheckResult);
    } catch (final Throwable throwable) {
        handleResultForAsyncAvailabilityCheck_Error(rows, throwable);
    }
}
Also used : AvailabilityMultiResult(de.metas.purchasecandidate.availability.AvailabilityMultiResult) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 AvailabilityMultiResult (de.metas.purchasecandidate.availability.AvailabilityMultiResult)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 LogManager (de.metas.logging.LogManager)1 PurchaseCandidatesGroup (de.metas.purchasecandidate.PurchaseCandidatesGroup)1 PurchaseDemand (de.metas.purchasecandidate.PurchaseDemand)1 PurchaseDemandWithCandidates (de.metas.purchasecandidate.PurchaseDemandWithCandidates)1 AvailabilityCheckService (de.metas.purchasecandidate.availability.AvailabilityCheckService)1 AvailabilityException (de.metas.purchasecandidate.availability.AvailabilityException)1 PurchaseCandidatesAvailabilityRequest (de.metas.purchasecandidate.availability.PurchaseCandidatesAvailabilityRequest)1 IView (de.metas.ui.web.view.IView)1 ViewChangesCollector (de.metas.ui.web.view.event.ViewChangesCollector)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)1 Services (de.metas.util.Services)1 CoalesceUtil (de.metas.util.lang.CoalesceUtil)1 TrackingId (de.metas.vendor.gateway.api.availability.TrackingId)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1