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