use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getDocumentPrint.
@GetMapping("/{windowId}/{documentId}/print/{filename:.*}")
public ResponseEntity<byte[]> getDocumentPrint(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentIdStr, @PathVariable("filename") final String filename) {
userSession.assertLoggedIn();
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
final DocumentPrint documentPrint = documentCollection.createDocumentPrint(documentPath);
final byte[] reportData = documentPrint.getReportData();
final String reportContentType = documentPrint.getReportContentType();
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType(reportContentType));
headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + filename + "\"");
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
final ResponseEntity<byte[]> response = new ResponseEntity<>(reportData, headers, HttpStatus.OK);
return response;
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class WindowRestController method deleteRootDocument.
@DeleteMapping("/{windowId}/{documentId}")
public List<JSONDocument> deleteRootDocument(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
return deleteDocuments(ImmutableList.of(documentPath));
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getDocumentFieldDropdown.
@GetMapping("/{windowId}/{documentId}/{tabId}/{rowId}/field/{fieldName}/dropdown")
public JSONLookupValuesList getDocumentFieldDropdown(//
@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 getDocumentFieldDropdown(documentPath, fieldName);
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class DocumentCollection method getDocumentPath.
/**
* Retrieves document path for given ZoomInto info.
*
* @param zoomIntoInfo
*/
public DocumentPath getDocumentPath(@NonNull final DocumentZoomIntoInfo zoomIntoInfo) {
if (!zoomIntoInfo.isRecordIdPresent()) {
throw new IllegalArgumentException("recordId must be set in " + zoomIntoInfo);
}
//
// Find the root window ID
final WindowId zoomIntoWindowIdEffective = getWindowId(zoomIntoInfo);
final DocumentEntityDescriptor rootEntityDescriptor = getDocumentEntityDescriptor(zoomIntoWindowIdEffective);
final String zoomIntoTableName = zoomIntoInfo.getTableName();
// (i.e. root descriptor's table is matching record's table)
if (Objects.equals(rootEntityDescriptor.getTableName(), zoomIntoTableName)) {
final DocumentId rootDocumentId = DocumentId.of(zoomIntoInfo.getRecordId());
return DocumentPath.rootDocumentPath(zoomIntoWindowIdEffective, rootDocumentId);
} else //
// We are dealing with an included document
{
// Search the root descriptor for any child entity descriptor which would match record's TableName
final List<DocumentEntityDescriptor> childEntityDescriptors = rootEntityDescriptor.getIncludedEntities().stream().filter(includedEntityDescriptor -> Objects.equals(includedEntityDescriptor.getTableName(), zoomIntoTableName)).collect(ImmutableList.toImmutableList());
if (childEntityDescriptors.isEmpty()) {
throw new EntityNotFoundException("Cannot find the detail tab to zoom into").setParameter("zoomIntoInfo", zoomIntoInfo).setParameter("zoomIntoWindowId", zoomIntoWindowIdEffective).setParameter("rootEntityDescriptor", rootEntityDescriptor);
} else if (childEntityDescriptors.size() > 1) {
logger.warn("More then one child descriptors matched our root descriptor. Picking the fist one. \nRoot descriptor: {} \nChild descriptors: {}", rootEntityDescriptor, childEntityDescriptors);
}
//
final DocumentEntityDescriptor childEntityDescriptor = childEntityDescriptors.get(0);
// Find the root DocumentId
final DocumentId rowId = DocumentId.of(zoomIntoInfo.getRecordId());
final DocumentId rootDocumentId = DocumentQuery.ofRecordId(childEntityDescriptor, rowId).retrieveParentDocumentId(rootEntityDescriptor);
//
return DocumentPath.includedDocumentPath(zoomIntoWindowIdEffective, rootDocumentId, childEntityDescriptor.getDetailId(), rowId);
}
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ADProcessPostProcessService method extractSingleDocumentPath.
private static final DocumentPath extractSingleDocumentPath(final RecordsToOpen recordsToOpen) {
final TableRecordReference recordRef = recordsToOpen.getSingleRecord();
final int documentId = recordRef.getRecord_ID();
WindowId windowId = WindowId.fromNullableJson(recordsToOpen.getWindowIdString());
if (windowId == null) {
windowId = WindowId.ofIntOrNull(RecordZoomWindowFinder.findAD_Window_ID(recordRef));
}
return DocumentPath.rootDocumentPath(windowId, documentId);
}
Aggregations