Search in sources :

Example 6 with CreateViewRequest

use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.

the class PickingSlotViewFactory method createView.

/**
 * This method is called once for each shipment schedule (left-hand side) and creates the respective picking view (right-hand side)
 *
 * @param request
 * @param allShipmentScheduleIds the shipment schedule IDs to display picking slots for; <br>
 *            may be {@code null} or empty, in this case we assume that only the given {@code request}'s {@code shipmentScheduleId} is available.
 * @return
 */
public PickingSlotView createView(@NonNull final CreateViewRequest request, @Nullable final List<Integer> allShipmentScheduleIds) {
    final CreateViewRequest requestEffective = request.unwrapFiltersAndCopy(getFilterDescriptorsProvider());
    final ViewId pickingViewId = requestEffective.getParentViewId();
    final DocumentId pickingRowId = requestEffective.getParentRowId();
    final ViewId pickingSlotViewId = PickingSlotViewsIndexStorage.createViewId(pickingViewId, pickingRowId);
    final int shipmentScheduleId = extractCurrentShipmentScheduleId(requestEffective);
    final PickingSlotRepoQuery query = createPickingSlotRowsQuery(requestEffective, allShipmentScheduleIds);
    final Supplier<List<PickingSlotRow>> rowsSupplier = () -> pickingSlotRepo.retrieveRows(query);
    return PickingSlotView.builder().viewId(pickingSlotViewId).parentViewId(pickingViewId).parentRowId(pickingRowId).currentShipmentScheduleId(shipmentScheduleId).rowsSupplier(rowsSupplier).additionalRelatedProcessDescriptors(createAdditionalRelatedProcessDescriptors()).filters(requestEffective.getFilters().getFilters()).build();
}
Also used : ViewId(de.metas.ui.web.view.ViewId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Example 7 with CreateViewRequest

use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.

the class PickingSlotViewsIndexStorage method getOrCreatePickingSlotView.

private PickingSlotView getOrCreatePickingSlotView(@NonNull final ViewId pickingSlotViewId, final boolean create) {
    final PackageableView packageableView = getPackageableViewByPickingSlotViewId(pickingSlotViewId);
    final DocumentId packageableRowId = extractRowId(pickingSlotViewId);
    if (create) {
        return packageableView.computePickingSlotViewIfAbsent(packageableRowId, () -> {
            final PackageableRow packageableRow = packageableView.getById(packageableRowId);
            final CreateViewRequest createViewRequest = CreateViewRequest.builder(PickingConstants.WINDOWID_PickingSlotView, JSONViewDataType.includedView).setParentViewId(packageableView.getViewId()).setParentRowId(packageableRow.getId()).build();
            // provide all pickingView's M_ShipmentSchedule_IDs to the factory, because we want to show the same picking slots and picked HU-rows for all of them.
            final List<Integer> allShipmentScheduleIds = packageableView.streamByIds(DocumentIdsSelection.ALL).map(PackageableRow::cast).map(PackageableRow::getShipmentScheduleId).collect(Collectors.toList());
            return pickingSlotViewFactory.createView(createViewRequest, allShipmentScheduleIds);
        });
    } else {
        return packageableView.getPickingSlotViewOrNull(packageableRowId);
    }
}
Also used : PackageableRow(de.metas.ui.web.picking.packageable.PackageableRow) PackageableView(de.metas.ui.web.picking.packageable.PackageableView) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Example 8 with CreateViewRequest

use of de.metas.ui.web.view.CreateViewRequest in project metasfresh-webui-api by metasfresh.

the class BoardRestController method createNewCardsView.

@PostMapping("/{boardId}/newCardsView")
public JSONViewResult createNewCardsView(@PathVariable("boardId") final int boardId) {
    userSession.assertLoggedIn();
    final BoardDescriptor boardDescriptor = boardsRepo.getBoardDescriptor(boardId);
    final CreateViewRequest request = CreateViewRequest.builder(boardDescriptor.getDocumentWindowId(), JSONViewDataType.list).setStickyFilters(boardDescriptor.getDocumentFilters()).build();
    final IView view = viewsRepo.createView(request);
    addActiveNewCardsView(boardId, view);
    return toJSONCardsViewResult(boardId, view, userSession.getAD_Language());
}
Also used : IView(de.metas.ui.web.view.IView) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

CreateViewRequest (de.metas.ui.web.view.CreateViewRequest)8 ViewId (de.metas.ui.web.view.ViewId)5 ImmutableList (com.google.common.collect.ImmutableList)2 DocumentFilterDescriptorsProvider (de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider)2 IView (de.metas.ui.web.view.IView)2 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 WindowId (de.metas.ui.web.window.datatypes.WindowId)2 Set (java.util.Set)2 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 IHUQueryBuilder (de.metas.handlingunits.IHUQueryBuilder)1 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)1 Constants (de.metas.handlingunits.attribute.Constants)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 IMsgBL (de.metas.i18n.IMsgBL)1 ITranslatableString (de.metas.i18n.ITranslatableString)1 LogManager (de.metas.logging.LogManager)1 PickingSlotQuery (de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery)1