use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class ASIViewRowAttributes method toJson.
@Override
public JSONViewRowAttributes toJson(final JSONOptions jsonOpts) {
final DocumentPath documentPath = getDocumentPath();
final JSONViewRowAttributes jsonDocument = new JSONViewRowAttributes(documentPath);
final List<JSONDocumentField> jsonFields = asiDoc.getFieldViews().stream().map(field -> toJSONDocumentField(field, jsonOpts)).collect(Collectors.toList());
jsonDocument.setFields(jsonFields);
return jsonDocument;
}
use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class WindowRestController method deleteDocuments.
private List<JSONDocument> deleteDocuments(final List<DocumentPath> documentPaths) {
userSession.assertLoggedIn();
final JSONOptions jsonOpts = newJSONOptions().setShowAdvancedFields(false).build();
return Execution.callInNewExecution("window.delete", () -> {
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
documentCollection.deleteAll(documentPaths, changesCollector);
return JSONDocument.ofEvents(changesCollector, jsonOpts);
});
}
use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class WindowRestController method patchDocument.
private List<JSONDocument> patchDocument(final DocumentPath documentPath, final boolean advanced, final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
final JSONOptions jsonOpts = newJSONOptions().setShowAdvancedFields(advanced).build();
return Execution.callInNewExecution("window.commit", () -> patchDocument0(documentPath, events, jsonOpts));
}
use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class WindowRestController method getDocumentReferences.
@GetMapping(value = "/{windowId}/{documentId}/{tabId}/{rowId}/references")
public JSONDocumentReferencesGroup getDocumentReferences(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @PathVariable("tabId") final String tabIdStr, @PathVariable("rowId") final String rowIdStr) {
userSession.assertLoggedIn();
// Get document references
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, tabIdStr, rowIdStr);
final List<DocumentReference> documentReferences = documentReferencesService.getDocumentReferences(documentPath);
final JSONOptions jsonOpts = newJSONOptions().build();
return JSONDocumentReferencesGroup.builder().caption("References").references(JSONDocumentReference.ofList(documentReferences, jsonOpts)).build();
}
use of de.metas.ui.web.window.datatypes.json.JSONOptions 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