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);
}
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();
}
Aggregations