use of de.metas.ui.web.window.datatypes.json.JSONDocument in project metasfresh-webui-api by metasfresh.
the class WindowQuickInputRestController method complete.
@PostMapping("{quickInputId}/complete")
public JSONDocument complete(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentIdStr, //
@PathVariable("tabId") final String tabIdStr, //
@PathVariable("quickInputId") final String quickInputIdStr) {
userSession.assertLoggedIn();
final QuickInputPath quickInputPath = QuickInputPath.of(windowIdStr, documentIdStr, tabIdStr, quickInputIdStr);
final IDocumentChangesCollector changesCollector = NullDocumentChangesCollector.instance;
return Execution.callInNewExecution("quickInput-writable-" + quickInputPath, () -> {
return forQuickInputWritable(quickInputPath, changesCollector, quickInput -> {
final Document document = quickInput.complete();
return JSONDocument.ofDocument(document, newJSONOptions());
});
});
}
use of de.metas.ui.web.window.datatypes.json.JSONDocument in project metasfresh-webui-api by metasfresh.
the class AddressRestController method getAddressDocument.
@RequestMapping(value = "/{docId}", method = RequestMethod.GET)
public JSONDocument getAddressDocument(@PathVariable("docId") final int docId) {
userSession.assertLoggedIn();
final Document addressDoc = addressRepo.getAddressDocumentForReading(docId);
return JSONDocument.ofDocument(addressDoc, newJsonOpts());
}
use of de.metas.ui.web.window.datatypes.json.JSONDocument in project metasfresh-webui-api by metasfresh.
the class WindowRestController method duplicate.
@PostMapping("/{windowId}/{documentId}/duplicate")
public JSONDocument duplicate(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced) {
userSession.assertLoggedIn();
final DocumentPath fromDocumentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), DocumentId.of(documentIdStr));
final Document documentCopy = documentCollection.duplicateDocument(fromDocumentPath);
return JSONDocument.ofDocument(documentCopy, newJSONOptions().setShowAdvancedFields(advanced).build());
}
use of de.metas.ui.web.window.datatypes.json.JSONDocument 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.datatypes.json.JSONDocument in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getData.
private List<JSONDocument> getData(final DocumentPath documentPath, final String fieldsListStr, final boolean advanced, final List<DocumentQueryOrderBy> orderBys) {
userSession.assertLoggedIn();
final JSONOptions jsonOpts = newJSONOptions().setShowAdvancedFields(advanced).setDataFieldsList(fieldsListStr).build();
return documentCollection.forRootDocumentReadonly(documentPath, rootDocument -> {
List<Document> documents;
if (documentPath.isRootDocument()) {
documents = ImmutableList.of(rootDocument);
} else if (documentPath.isAnyIncludedDocument()) {
documents = rootDocument.getIncludedDocuments(documentPath.getDetailId(), orderBys).toList();
} else if (documentPath.isSingleIncludedDocument()) {
documents = ImmutableList.of(rootDocument.getIncludedDocument(documentPath.getDetailId(), documentPath.getSingleRowId()));
} else {
throw new InvalidDocumentPathException(documentPath);
}
return JSONDocument.ofDocumentsList(documents, jsonOpts);
});
}
Aggregations