use of de.metas.ui.web.handlingunits.HUEditorView in project metasfresh-webui-api by metasfresh.
the class WEBUI_Add_Batch_SerialNo_To_CUs method removeHUsIfDestroyed.
/**
* @return true if at least one HU was removed
*/
private boolean removeHUsIfDestroyed(final Collection<HuId> huIds) {
final ImmutableSet<HuId> destroyedHUIds = huIds.stream().distinct().map(huId -> load(huId, I_M_HU.class)).filter(Services.get(IHandlingUnitsBL.class)::isDestroyed).map(I_M_HU::getM_HU_ID).map(HuId::ofRepoId).collect(ImmutableSet.toImmutableSet());
if (destroyedHUIds.isEmpty()) {
return false;
}
final HUEditorView view = getView();
final boolean changes = view.removeHUIds(destroyedHUIds);
return changes;
}
use of de.metas.ui.web.handlingunits.HUEditorView 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
Objects::nonNull).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();
}
use of de.metas.ui.web.handlingunits.HUEditorView in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_IssueTopLevelHUs method doIt.
@Override
protected String doIt() {
final Stream<HUEditorRow> selectedTopLevelHuRows = streamSelectedRows(HUEditorRowFilter.select(Select.ONLY_TOPLEVEL));
final List<I_M_HU> hus = retrieveEligibleHUEditorRows(selectedTopLevelHuRows).map(HUEditorRow::getM_HU).collect(ImmutableList.toImmutableList());
if (hus.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final PPOrderLinesView ppOrderView = getPPOrderView().get();
final PPOrderId ppOrderId = ppOrderView.getPpOrderId();
Services.get(IHUPPOrderBL.class).createIssueProducer(ppOrderId).createIssues(hus);
final HUEditorView huEditorView = getView();
huEditorView.removeHUsAndInvalidate(hus);
ppOrderView.invalidateAll();
return MSG_OK;
}
use of de.metas.ui.web.handlingunits.HUEditorView in project metasfresh-webui-api by metasfresh.
the class HUsToPickViewFactory method filterView.
@Override
public IView filterView(final IView view, final JSONFilterViewRequest filterViewRequest, Supplier<IViewsRepository> viewsRepo) {
final CreateViewRequest.Builder filterViewBuilder = CreateViewRequest.filterViewBuilder(view, filterViewRequest);
if (view instanceof HUEditorView) {
final HUEditorView huEditorView = HUEditorView.cast(view);
filterViewBuilder.setParameters(huEditorView.getParameters());
final ViewId parentViewId = huEditorView.getParentViewId();
final IView parentView = viewsRepo.get().getView(parentViewId);
if (parentView instanceof PickingSlotView) {
final PickingSlotView pickingSlotView = PickingSlotView.cast(parentView);
filterViewBuilder.setParameter(HUsToPickViewFilters.PARAM_CurrentShipmentScheduleId, pickingSlotView.getCurrentShipmentScheduleId());
}
}
final CreateViewRequest createViewRequest = filterViewBuilder.build();
return createView(createViewRequest);
}
use of de.metas.ui.web.handlingunits.HUEditorView in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_HU_SecurPharmScan method doIt.
@Override
protected String doIt() {
final SecurPharmHUAttributesScanner scanner = securPharmService.newHUScanner();
final SecurPharmHUAttributesScannerResult result = scanner.scanAndUpdateHUAttributes(getDataMatrix(), getSelectedHuId());
//
// Update view
final HUEditorView view = getView();
if (result.getExtractedCUId() != null) {
view.addHUId(result.getExtractedCUId());
}
view.invalidateAll();
return result.getResultMessageAndCode();
}
Aggregations