Search in sources :

Example 1 with MutableInt

use of org.adempiere.util.lang.MutableInt in project metasfresh-webui-api by metasfresh.

the class ViewsRepository method notifyRecordsChanged.

@Override
@Async
public void notifyRecordsChanged(@NonNull final Set<TableRecordReference> recordRefs) {
    if (recordRefs.isEmpty()) {
        logger.trace("No changed records provided. Skip notifying views.");
        return;
    }
    final MutableInt notifiedCount = MutableInt.zero();
    streamAllViews().forEach(view -> {
        view.notifyRecordsChanged(recordRefs);
        notifiedCount.incrementAndGet();
    });
    logger.debug("Notified {} views about changed records: {}", notifiedCount, recordRefs);
}
Also used : MutableInt(org.adempiere.util.lang.MutableInt) Async(org.springframework.scheduling.annotation.Async)

Example 2 with MutableInt

use of org.adempiere.util.lang.MutableInt in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_Receipt_Base method checkPreconditionsApplicable.

@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!isViewClass(HUEditorView.class)) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("The current view is not an HUEditorView");
    }
    final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
    if (selectedRowIds.isEmpty()) {
        return ProcessPreconditionsResolution.rejectBecauseNoSelection();
    }
    final MutableInt checkedDocumentsCount = new MutableInt(0);
    final ProcessPreconditionsResolution firstRejection = getView(HUEditorView.class).streamByIds(selectedRowIds).filter(document -> document.isPureHU()).peek(// count checked documents
    document -> checkedDocumentsCount.incrementAndGet()).map(// create reject resolution if any
    document -> rejectResolutionOrNull(document)).filter(// filter out those which are not errors
    resolution -> resolution != null).findFirst().orElse(null);
    if (firstRejection != null) {
        // found a record which is not eligible => don't run the process
        return firstRejection;
    }
    if (checkedDocumentsCount.getValue() <= 0) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("no eligible rows");
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : MutableInt(org.adempiere.util.lang.MutableInt) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) ViewBasedProcessTemplate(de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) IProcessPrecondition(de.metas.process.IProcessPrecondition) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) MutableInt(org.adempiere.util.lang.MutableInt) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView)

Aggregations

MutableInt (org.adempiere.util.lang.MutableInt)2 IProcessPrecondition (de.metas.process.IProcessPrecondition)1 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)1 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)1 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)1 ViewBasedProcessTemplate (de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate)1 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)1 Async (org.springframework.scheduling.annotation.Async)1