use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getIncludedDocumentActions.
@GetMapping("/{windowId}/{documentId}/{tabId}/{rowId}/actions")
public JSONDocumentActionsList getIncludedDocumentActions(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @PathVariable("tabId") final String tabIdStr, @PathVariable("rowId") final String rowIdStr, @RequestParam(name = "disabled", defaultValue = "false") final boolean returnDisabled) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, tabIdStr, rowIdStr);
final Set<TableRecordReference> selectedIncludedRecords = ImmutableSet.of();
return getDocumentActions(documentPath, selectedIncludedRecords, returnDisabled);
}
use of org.adempiere.util.lang.impl.TableRecordReference 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 org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class ADProcessPostProcessService method createViewRequest.
private static final CreateViewRequest createViewRequest(final RecordsToOpen recordsToOpen, final Set<DocumentPath> referencingDocumentPaths, final ViewId parentViewId) {
final List<TableRecordReference> recordRefs = recordsToOpen.getRecords();
if (recordRefs.isEmpty()) {
// shall not happen
return null;
}
// optional
final WindowId windowId_Override = WindowId.fromNullableJson(recordsToOpen.getWindowIdString());
//
// Create view create request builders from current records
final Map<WindowId, CreateViewRequest.Builder> viewRequestBuilders = new HashMap<>();
for (final TableRecordReference recordRef : recordRefs) {
final WindowId recordWindowId = windowId_Override != null ? windowId_Override : WindowId.ofIntOrNull(RecordZoomWindowFinder.findAD_Window_ID(recordRef));
final CreateViewRequest.Builder viewRequestBuilder = viewRequestBuilders.computeIfAbsent(recordWindowId, key -> CreateViewRequest.builder(recordWindowId, JSONViewDataType.grid));
viewRequestBuilder.addFilterOnlyId(recordRef.getRecord_ID());
}
// If there is no view create request builder there stop here (shall not happen)
if (viewRequestBuilders.isEmpty()) {
return null;
}
// Create the view create request from first builder that we have.
if (viewRequestBuilders.size() > 1) {
logger.warn("More than one views to be created found for {}. Creating only the first view.", recordRefs);
}
final CreateViewRequest viewRequest = viewRequestBuilders.values().iterator().next().setReferencingDocumentPaths(referencingDocumentPaths).setParentViewId(parentViewId).build();
return viewRequest;
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_IssueReceipt_BarcodeLauncher method doIt.
@Override
protected String doIt() throws Exception {
final int orderLineId = OrderCheckupBarcode.fromBarcodeString(p_Barcode).getC_OrderLine_ID();
final int ppOrderId = Services.get(IPPOrderDAO.class).retrievePPOrderIdByOrderLineId(orderLineId);
if (ppOrderId <= 0) {
throw new EntityNotFoundException("@NotFound@ @PP_Order_ID@");
}
final TableRecordReference ppOrderRef = TableRecordReference.of(org.eevolution.model.I_PP_Order.Table_Name, ppOrderId);
getResult().setRecordToOpen(ppOrderRef, PPOrderConstants.AD_WINDOW_ID_IssueReceipt.toInt(), OpenTarget.GridView);
return MSG_OK;
}
use of org.adempiere.util.lang.impl.TableRecordReference in project metasfresh-webui-api by metasfresh.
the class WEBUI_SalesOrder_PurchaseView_Launcher method checkPreconditionsApplicable.
@Override
public ProcessPreconditionsResolution checkPreconditionsApplicable(final IProcessPreconditionsContext context) {
if (!context.isSingleSelection()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("one and only one order shall be selected");
}
// Only sales orders
final I_C_Order salesOrder = context.getSelectedModel(I_C_Order.class);
if (!salesOrder.isSOTrx()) {
return ProcessPreconditionsResolution.rejectWithInternalReason("only sales orders are allowed");
}
final String docStatus = salesOrder.getDocStatus();
if (!IDocument.STATUS_Drafted.equals(docStatus) && !IDocument.STATUS_Completed.equals(docStatus)) {
return ProcessPreconditionsResolution.rejectWithInternalReason("only draft or completed orders are allowed");
}
// At least one sales order line shall be selected
final //
Set<TableRecordReference> selectedOrderLineRefs = context.getSelectedIncludedRecords();
if (selectedOrderLineRefs.isEmpty()) {
return ProcessPreconditionsResolution.rejectBecauseNoSelection();
}
return ProcessPreconditionsResolution.accept();
}
Aggregations