use of de.metas.ui.web.window.model.IDocumentChangesCollector in project metasfresh-webui-api by metasfresh.
the class WindowRestController method patchDocument0.
private List<JSONDocument> patchDocument0(final DocumentPath documentPath, final List<JSONDocumentChangedEvent> events, final JSONOptions jsonOpts) {
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
documentCollection.forDocumentWritable(documentPath, changesCollector, document -> {
document.processValueChanges(events, REASON_Value_DirectSetFromCommitAPI);
changesCollector.setPrimaryChange(document.getDocumentPath());
// void
return null;
});
// Extract and send websocket events
final List<JSONDocument> jsonDocumentEvents = JSONDocument.ofEvents(changesCollector, jsonOpts);
websocketPublisher.convertAndPublish(jsonDocumentEvents);
return jsonDocumentEvents;
}
use of de.metas.ui.web.window.model.IDocumentChangesCollector in project metasfresh-webui-api by metasfresh.
the class ProcessRestController method processParametersChangeEvents.
@RequestMapping(value = "/{processId}/{pinstanceId}", method = RequestMethod.PATCH)
public List<JSONDocument> processParametersChangeEvents(//
@PathVariable("processId") final String processIdStr, //
@PathVariable("pinstanceId") final String pinstanceIdStr, //
@RequestBody final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
Check.assumeNotEmpty(events, "events is not empty");
final ProcessId processId = ProcessId.fromJson(processIdStr);
final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
final IProcessInstancesRepository instancesRepository = getRepository(processId);
return Execution.callInNewExecution("", () -> {
// get our collector to fill with the changes that we will record
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
instancesRepository.forProcessInstanceWritable(pinstanceId, changesCollector, processInstance -> {
processInstance.processParameterValueChanges(events, REASON_Value_DirectSetFromCommitAPI);
// void
return null;
});
return JSONDocument.ofEvents(changesCollector, newJSONOptions());
});
}
use of de.metas.ui.web.window.model.IDocumentChangesCollector in project metasfresh-webui-api by metasfresh.
the class ASIRestController method processChanges.
@PatchMapping("/{asiDocId}")
public List<JSONDocument> processChanges(//
@PathVariable("asiDocId") final String asiDocIdStr, //
@RequestBody final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
final DocumentId asiDocId = DocumentId.of(asiDocIdStr);
return Execution.callInNewExecution("processChanges", () -> {
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
asiRepo.processASIDocumentChanges(asiDocId, events, changesCollector);
return JSONDocument.ofEvents(changesCollector, newJsonOpts());
});
}
use of de.metas.ui.web.window.model.IDocumentChangesCollector in project metasfresh-webui-api by metasfresh.
the class WindowQuickInputRestController method processChanges.
@PatchMapping("/{quickInputId}")
public List<JSONDocument> processChanges(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentIdStr, //
@PathVariable("tabId") final String tabIdStr, //
@PathVariable("quickInputId") final String quickInputIdStr, @RequestBody final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
final QuickInputPath quickInputPath = QuickInputPath.of(windowIdStr, documentIdStr, tabIdStr, quickInputIdStr);
return Execution.callInNewExecution("quickInput-writable-" + quickInputPath, () -> {
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
forQuickInputWritable(quickInputPath, changesCollector, quickInput -> {
quickInput.processValueChanges(events);
changesCollector.setPrimaryChange(quickInput.getDocumentPath());
// void
return null;
});
// Extract and send websocket events
final List<JSONDocument> jsonDocumentEvents = JSONDocument.ofEvents(changesCollector, newJSONOptions());
websocketPublisher.convertAndPublish(jsonDocumentEvents);
return jsonDocumentEvents;
});
}
Aggregations