use of de.metas.ui.web.window.descriptor.DetailId in project metasfresh-webui-api by metasfresh.
the class WindowQuickInputRestController method create.
@PostMapping
public JSONDocument create(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentIdStr, //
@PathVariable("tabId") final String tabIdStr) {
userSession.assertLoggedIn();
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath rootDocumentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
final DetailId detailId = DetailId.fromJson(tabIdStr);
return Execution.callInNewExecution("quickInput.create", () -> {
final QuickInput quickInput = documentsCollection.forRootDocumentReadonly(rootDocumentPath, rootDocument -> {
// Make sure we can edit our root document. Fail fast.
DocumentPermissionsHelper.assertCanEdit(rootDocument, userSession.getUserRolePermissions());
final DocumentEntityDescriptor includedDocumentDescriptor = rootDocument.getEntityDescriptor().getIncludedEntityByDetailId(detailId);
final QuickInputDescriptor quickInputDescriptor = quickInputDescriptors.getQuickInputEntityDescriptor(includedDocumentDescriptor);
try {
return QuickInput.builder().setQuickInputDescriptor(quickInputDescriptor).setRootDocumentPath(rootDocument.getDocumentPath()).build().bindRootDocument(rootDocument).assertTargetWritable();
} catch (Exception ex) {
// see https://github.com/metasfresh/metasfresh-webui-frontend/issues/487
throw EntityNotFoundException.wrapIfNeeded(ex);
}
});
commit(quickInput);
return JSONDocument.ofDocument(quickInput.getQuickInputDocument(), newJSONOptions());
});
}
Aggregations