use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class AddressRepository method processAddressDocumentChanges.
public void processAddressDocumentChanges(final int addressDocIdInt, final List<JSONDocumentChangedEvent> events, final IDocumentChangesCollector changesCollector) {
final DocumentId addressDocId = DocumentId.of(addressDocIdInt);
final Document addressDoc = getAddressDocumentForWriting(addressDocId, changesCollector);
addressDoc.processValueChanges(events, REASON_ProcessAddressDocumentChanges);
Services.get(ITrxManager.class).getCurrentTrxListenerManagerOrAutoCommit().newEventListener(TrxEventTiming.AFTER_COMMIT).registerHandlingMethod(trx -> putAddressDocument(addressDoc));
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class DocumentAttachmentsRestController method getAttachmentById.
@GetMapping("/{id}")
public ResponseEntity<byte[]> getAttachmentById(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId, @PathVariable("id") final String entryIdStr) {
userSession.assertLoggedIn();
final DocumentId entryId = DocumentId.of(entryIdStr);
final IDocumentAttachmentEntry entry = getDocumentAttachments(windowIdStr, documentId).getEntry(entryId);
final AttachmentEntryType type = entry.getType();
if (type == AttachmentEntryType.Data) {
return extractResponseEntryFromData(entry);
} else if (type == AttachmentEntryType.URL) {
return extractResponseEntryFromURL(entry);
} else {
throw new AdempiereException("Invalid attachment entry").setParameter("reason", "invalid type").setParameter("type", type).setParameter("entry", entry);
}
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class DocumentAttachmentsRestController method deleteAttachmentById.
@DeleteMapping("/{id}")
public void deleteAttachmentById(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentId, //
@PathVariable("id") final String entryIdStr) {
userSession.assertLoggedIn();
final DocumentId entryId = DocumentId.of(entryIdStr);
getDocumentAttachments(windowIdStr, documentId).deleteEntry(entryId);
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class ProcessRestController method getReport.
@RequestMapping(value = "/{processId}/{pinstanceId}/print/{filename:.*}", method = RequestMethod.GET)
public ResponseEntity<byte[]> getReport(//
@PathVariable("processId") final String processIdStr, //
@PathVariable("pinstanceId") final String pinstanceIdStr, //
@PathVariable("filename") final String filename) {
userSession.assertLoggedIn();
final ProcessId processId = ProcessId.fromJson(processIdStr);
final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
final IProcessInstancesRepository instancesRepository = getRepository(processId);
final ProcessInstanceResult executionResult = instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> processInstance.getExecutionResult());
final OpenReportAction action = executionResult.getAction(OpenReportAction.class);
final String reportFilename = action.getFilename();
final String reportContentType = action.getContentType();
final byte[] reportData = action.getReportData();
final String reportFilenameEffective = Util.coalesce(filename, reportFilename, "");
final HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType(reportContentType));
headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + reportFilenameEffective + "\"");
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.DocumentId in project metasfresh-webui-api by metasfresh.
the class ProcessRestController method getParameterDropdown.
@RequestMapping(value = "/{processId}/{pinstanceId}/field/{parameterName}/dropdown", method = RequestMethod.GET)
public JSONLookupValuesList getParameterDropdown(//
@PathVariable("processId") final String processIdStr, //
@PathVariable("pinstanceId") final String pinstanceIdStr, //
@PathVariable("parameterName") final String parameterName) {
userSession.assertLoggedIn();
final ProcessId processId = ProcessId.fromJson(processIdStr);
final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
final IProcessInstancesRepository instancesRepository = getRepository(processId);
return instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> processInstance.getParameterLookupValues(parameterName)).transform(JSONLookupValuesList::ofLookupValuesList);
}
Aggregations