Search in sources :

Example 1 with TableRecordReference

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);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) 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 2 with TableRecordReference

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);
}
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 3 with TableRecordReference

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;
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) WindowId(de.metas.ui.web.window.datatypes.WindowId) HashMap(java.util.HashMap) Builder(lombok.Builder) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Example 4 with TableRecordReference

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;
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) IPPOrderDAO(org.eevolution.api.IPPOrderDAO) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException)

Example 5 with TableRecordReference

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();
}
Also used : I_C_Order(de.metas.adempiere.model.I_C_Order) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference)

Aggregations

TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)19 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)6 WindowId (de.metas.ui.web.window.datatypes.WindowId)5 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)4 IView (de.metas.ui.web.view.IView)3 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)3 AdempiereException (org.adempiere.exceptions.AdempiereException)3 ProcessExecutionResult (de.metas.process.ProcessExecutionResult)2 ViewId (de.metas.ui.web.view.ViewId)2 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 List (java.util.List)2 Set (java.util.Set)2 NonNull (lombok.NonNull)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 Suppliers (com.google.common.base.Suppliers)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 I_C_Order (de.metas.adempiere.model.I_C_Order)1 Event (de.metas.event.Event)1