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