Search in sources :

Example 36 with DocumentPath

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

the class HighVolumeReadWriteIncludedDocumentsCollection method getDocumentById.

@Override
public Document getDocumentById(@NonNull final DocumentId documentId) {
    // Try documents which are new and/or have changes in progress, but are not yet saved
    final Document documentWithChanges = getChangedDocumentOrNull(documentId);
    if (documentWithChanges != null) {
        return documentWithChanges;
    }
    // Retrieve from repository
    final Document documentRetrieved = DocumentQuery.builder(entityDescriptor).setParentDocument(parentDocument).setRecordId(documentId).setChangesCollector(NullDocumentChangesCollector.instance).retriveDocumentOrNull();
    if (documentRetrieved == null) {
        final DocumentPath documentPath = parentDocumentPath.createChildPath(detailId, documentId);
        throw new DocumentNotFoundException(documentPath);
    }
    return documentRetrieved.copy(parentDocument, parentDocument.isWritable() ? CopyMode.CheckOutWritable : CopyMode.CheckInReadonly);
}
Also used : DocumentNotFoundException(de.metas.ui.web.window.exceptions.DocumentNotFoundException) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 37 with DocumentPath

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

the class ASIDocument method bindContextDocumentIfPossible.

public ASIDocument bindContextDocumentIfPossible(@NonNull final DocumentCollection documentsCollection) {
    final DocumentPath contextDocumentPath = descriptor.getContextDocumentPath();
    if (contextDocumentPath == null) {
        return this;
    }
    if (!documentsCollection.isWindowIdSupported(contextDocumentPath.getWindowIdOrNull())) {
        return this;
    }
    final Document contextDocument = documentsCollection.getDocumentReadonly(contextDocumentPath);
    data.setShadowParentDocumentEvaluatee(contextDocument.asEvaluatee());
    return this;
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) Document(de.metas.ui.web.window.model.Document)

Example 38 with DocumentPath

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

the class ADProcessPostProcessService method createResultAction.

private ResultAction createResultAction(final ProcessInfo processInfo, final ProcessExecutionResult processExecutionResult) {
    final File reportTempFile = saveReportToDiskIfAny(processExecutionResult);
    final RecordsToOpen recordsToOpen = processExecutionResult.getRecordsToOpen();
    // Open report
    if (reportTempFile != null) {
        logger.debug("The processExecutionResult specifies reportTempFile={}", reportTempFile);
        return OpenReportAction.builder().filename(processExecutionResult.getReportFilename()).contentType(processExecutionResult.getReportContentType()).tempFile(reportTempFile).build();
    } else // Create & open view from Records
    if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.GridView) {
        logger.debug("The processExecutionResult specifies recordsToOpen={}", recordsToOpen);
        final Set<DocumentPath> referencingDocumentPaths = recordsToOpen.isAutomaticallySetReferencingDocumentPaths() ? extractReferencingDocumentPaths(processInfo) : null;
        final String parentViewIdStr = processExecutionResult.getWebuiViewId();
        final ViewId parentViewId = parentViewIdStr != null ? ViewId.ofViewIdString(parentViewIdStr) : null;
        final CreateViewRequest viewRequest = createViewRequest(recordsToOpen, referencingDocumentPaths, parentViewId);
        final IView view = viewsRepo.createView(viewRequest);
        return OpenViewAction.builder().viewId(view.getViewId()).build();
    } else // Open existing view
    if (processExecutionResult.getWebuiViewToOpen() != null) {
        final WebuiViewToOpen viewToOpen = processExecutionResult.getWebuiViewToOpen();
        logger.debug("The processExecutionResult specifies viewToOpen={}", viewToOpen);
        final ViewOpenTarget target = viewToOpen.getTarget();
        if (ViewOpenTarget.IncludedView.equals(target)) {
            return OpenIncludedViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).build();
        } else if (ViewOpenTarget.ModalOverlay.equals(target)) {
            return OpenViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).modalOverlay(true).build();
        } else if (ViewOpenTarget.NewBrowserTab.equals(target)) {
            return OpenViewAction.builder().viewId(ViewId.ofViewIdString(viewToOpen.getViewId())).profileId(ViewProfileId.fromJson(viewToOpen.getProfileId())).modalOverlay(false).build();
        } else {
            throw new AdempiereException("Unknown target: " + target);
        }
    } else // Open single document
    if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocument) {
        final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
        return OpenSingleDocument.builder().documentPath(documentPath).modal(false).build();
    } else // Open single document
    if (recordsToOpen != null && recordsToOpen.getTarget() == OpenTarget.SingleDocumentModal) {
        final DocumentPath documentPath = extractSingleDocumentPath(recordsToOpen);
        return OpenSingleDocument.builder().documentPath(documentPath).modal(true).build();
    } else // Display QRCode to user
    if (processExecutionResult.getDisplayQRCode() != null) {
        return DisplayQRCodeAction.builder().code(processExecutionResult.getDisplayQRCode().getCode()).build();
    } else // 
    // No action
    {
        return null;
    }
}
Also used : TableRecordReferenceSet(org.adempiere.util.lang.impl.TableRecordReferenceSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) IView(de.metas.ui.web.view.IView) ViewOpenTarget(de.metas.process.ProcessExecutionResult.ViewOpenTarget) AdempiereException(org.adempiere.exceptions.AdempiereException) ViewId(de.metas.ui.web.view.ViewId) WebuiViewToOpen(de.metas.process.ProcessExecutionResult.WebuiViewToOpen) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) RecordsToOpen(de.metas.process.ProcessExecutionResult.RecordsToOpen) File(java.io.File) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest)

Example 39 with DocumentPath

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

the class WindowRestController method getDocumentFieldTypeahead.

/**
 * Typeahead for root document's field
 */
@GetMapping("/{windowId}/{documentId}/field/{fieldName}/typeahead")
public JSONLookupValuesList getDocumentFieldTypeahead(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("fieldName") final String fieldName, // 
@RequestParam(name = "query", required = true) final String query) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
    return getDocumentFieldTypeahead(documentPath, fieldName, query);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) 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 40 with DocumentPath

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

the class WindowRestController method getDocumentFieldZoomInto.

@ApiOperation("field current value's window layout to zoom into")
@GetMapping("/{windowId}/{documentId}/{tabId}/{rowId}/field/{fieldName}/zoomInto")
public JSONZoomInto getDocumentFieldZoomInto(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("tabId") final String tabId, // 
@PathVariable("rowId") final String rowId, // 
@PathVariable("fieldName") final String fieldName) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentId, tabId, rowId);
    return getDocumentFieldZoomInto(documentPath, fieldName);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)65 WindowId (de.metas.ui.web.window.datatypes.WindowId)29 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)22 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)20 GetMapping (org.springframework.web.bind.annotation.GetMapping)14 List (java.util.List)13 ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 DetailId (de.metas.ui.web.window.descriptor.DetailId)12 Set (java.util.Set)11 NonNull (lombok.NonNull)10 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)10 AdempiereException (org.adempiere.exceptions.AdempiereException)9 PostMapping (org.springframework.web.bind.annotation.PostMapping)9 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)7 ViewId (de.metas.ui.web.view.ViewId)6 Services (de.metas.util.Services)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)5