Search in sources :

Example 1 with DocumentIdsSelection

use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.

the class ViewRowIdsSelection method ofNullableStrings.

public static ViewRowIdsSelection ofNullableStrings(final String viewIdStr, final String rowIdsListStr) {
    if (viewIdStr == null || viewIdStr.isEmpty()) {
        return null;
    }
    final ViewId viewId = ViewId.ofViewIdString(viewIdStr);
    final DocumentIdsSelection rowIds = DocumentIdsSelection.ofCommaSeparatedString(rowIdsListStr);
    return new ViewRowIdsSelection(viewId, rowIds);
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection)

Example 2 with DocumentIdsSelection

use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.

the class ViewRowIdsSelection method ofNullableStrings.

public static ViewRowIdsSelection ofNullableStrings(String viewIdStr, Set<String> rowIdsStringSet) {
    if (viewIdStr == null || viewIdStr.isEmpty()) {
        return null;
    }
    final ViewId viewId = ViewId.ofViewIdString(viewIdStr);
    final DocumentIdsSelection rowIds = DocumentIdsSelection.ofStringSet(rowIdsStringSet);
    return new ViewRowIdsSelection(viewId, rowIds);
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection)

Example 3 with DocumentIdsSelection

use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.

the class WindowRestController method getDocumentActions.

@GetMapping("/{windowId}/{documentId}/actions")
public JSONDocumentActionsList getDocumentActions(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentId, @RequestParam(name = "selectedTabId", required = false) final String selectedTabIdStr, @RequestParam(name = "selectedRowIds", required = false) final String selectedRowIdsAsStr, @RequestParam(name = "disabled", defaultValue = "false") final boolean returnDisabled) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
    final DetailId selectedTabId = DetailId.fromJson(selectedTabIdStr);
    final DocumentIdsSelection selectedRowIds = DocumentIdsSelection.ofCommaSeparatedString(selectedRowIdsAsStr);
    final Set<TableRecordReference> selectedIncludedRecords = selectedRowIds.stream().map(rowId -> documentPath.createChildPath(selectedTabId, rowId)).map(documentCollection::getTableRecordReference).collect(ImmutableSet.toImmutableSet());
    return getDocumentActions(documentPath, selectedIncludedRecords, returnDisabled);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) WindowId(de.metas.ui.web.window.datatypes.WindowId) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with DocumentIdsSelection

use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.

the class ProcessRestController method createInstanceFromRequest.

@RequestMapping(value = "/{processId}", method = RequestMethod.POST)
public JSONProcessInstance createInstanceFromRequest(@PathVariable("processId") final String processIdStr, @RequestBody final JSONCreateProcessInstanceRequest jsonRequest) {
    userSession.assertLoggedIn();
    final ViewRowIdsSelection viewRowIdsSelection = jsonRequest.getViewRowIdsSelection();
    final ViewId viewId = viewRowIdsSelection != null ? viewRowIdsSelection.getViewId() : null;
    final DocumentIdsSelection viewSelectedRowIds = viewRowIdsSelection != null ? viewRowIdsSelection.getRowIds() : DocumentIdsSelection.EMPTY;
    // Get the effective singleDocumentPath, i.e.
    // * if provided, use it
    // * if not provided and we have a single selected row in the view, ask the view's row to provide the effective document path
    DocumentPath singleDocumentPath = jsonRequest.getSingleDocumentPath();
    if (singleDocumentPath == null && viewSelectedRowIds.isSingleDocumentId()) {
        final IView view = viewsRepo.getView(viewId);
        singleDocumentPath = view.getById(viewSelectedRowIds.getSingleDocumentId()).getDocumentPath();
    }
    final CreateProcessInstanceRequest request = CreateProcessInstanceRequest.builder().processId(ProcessId.fromJson(processIdStr)).singleDocumentPath(singleDocumentPath).selectedIncludedDocumentPaths(jsonRequest.getSelectedIncludedDocumentPaths()).viewRowIdsSelection(viewRowIdsSelection).parentViewRowIdsSelection(jsonRequest.getParentViewRowIdsSelection()).childViewRowIdsSelection(jsonRequest.getChildViewRowIdsSelection()).build();
    // Validate request's AD_Process_ID
    // (we are not using it, but just for consistency)
    request.assertProcessIdEquals(jsonRequest.getProcessId());
    final IProcessInstancesRepository instancesRepository = getRepository(request.getProcessId());
    return Execution.callInNewExecution("pinstance.create", () -> {
        final IProcessInstanceController processInstance = instancesRepository.createNewProcessInstance(request);
        return JSONProcessInstance.of(processInstance, newJSONOptions());
    });
}
Also used : IView(de.metas.ui.web.view.IView) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewId(de.metas.ui.web.view.ViewId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONCreateProcessInstanceRequest(de.metas.ui.web.process.json.JSONCreateProcessInstanceRequest) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DocumentIdsSelection

use of de.metas.ui.web.window.datatypes.DocumentIdsSelection in project metasfresh-webui-api by metasfresh.

the class PickingSlotsClearingViewBasedProcess method getSingleSelectedPackingHUsRow.

protected final HUEditorRow getSingleSelectedPackingHUsRow() {
    final DocumentIdsSelection selectedRowIds = getSelectedPackingHUsRowIds();
    final DocumentId rowId = selectedRowIds.getSingleDocumentId();
    return getPackingHUsView().getById(rowId);
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Aggregations

DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)25 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)8 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)6 IProcessPrecondition (de.metas.process.IProcessPrecondition)5 ProcessPreconditionsResolution (de.metas.process.ProcessPreconditionsResolution)5 List (java.util.List)5 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)5 ImmutableList (com.google.common.collect.ImmutableList)4 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)4 IView (de.metas.ui.web.view.IView)4 AdempiereException (org.adempiere.exceptions.AdempiereException)4 ImmutableSet (com.google.common.collect.ImmutableSet)3 ViewBasedProcessTemplate (de.metas.ui.web.process.adprocess.ViewBasedProcessTemplate)3 Collection (java.util.Collection)3 Set (java.util.Set)3 NonNull (lombok.NonNull)3 Services (org.adempiere.util.Services)3 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)2 I_M_HU (de.metas.handlingunits.model.I_M_HU)2 Param (de.metas.process.Param)2