Search in sources :

Example 11 with HUEditorView

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;
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) I_M_HU(de.metas.handlingunits.model.I_M_HU) HuId(de.metas.handlingunits.HuId) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView)

Example 12 with HUEditorView

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();
}
Also used : MutableInt(org.adempiere.util.lang.MutableInt) Objects(java.util.Objects) 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) Objects(java.util.Objects) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView)

Example 13 with HUEditorView

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;
}
Also used : PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PPOrderId(de.metas.material.planning.pporder.PPOrderId)

Example 14 with HUEditorView

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);
}
Also used : IView(de.metas.ui.web.view.IView) PickingSlotView(de.metas.ui.web.picking.pickingslot.PickingSlotView) ViewId(de.metas.ui.web.view.ViewId) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Example 15 with HUEditorView

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();
}
Also used : SecurPharmHUAttributesScannerResult(de.metas.vertical.pharma.securpharm.service.SecurPharmHUAttributesScannerResult) HUEditorView(de.metas.ui.web.handlingunits.HUEditorView) SecurPharmHUAttributesScanner(de.metas.vertical.pharma.securpharm.service.SecurPharmHUAttributesScanner)

Aggregations

HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)17 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)7 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)6 I_M_HU (de.metas.handlingunits.model.I_M_HU)5 HuId (de.metas.handlingunits.HuId)4 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)4 IProcessPrecondition (de.metas.process.IProcessPrecondition)3 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)3 DocumentCollection (de.metas.ui.web.window.model.DocumentCollection)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Param (de.metas.process.Param)2 HUEditorProcessTemplate (de.metas.ui.web.handlingunits.HUEditorProcessTemplate)2 PickingSlotView (de.metas.ui.web.picking.pickingslot.PickingSlotView)2 ViewId (de.metas.ui.web.view.ViewId)2 Collection (java.util.Collection)2 List (java.util.List)2 InterfaceWrapperHelper.load (org.adempiere.model.InterfaceWrapperHelper.load)2 Services (org.adempiere.util.Services)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Splitter (com.google.common.base.Splitter)1