Search in sources :

Example 1 with JSONOptions

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;
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONLayoutWidgetType(de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) ASILayout(de.metas.ui.web.pattribute.ASILayout) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Collectors(java.util.stream.Collectors) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) List(java.util.List) ViewRowAttributesLayout(de.metas.ui.web.view.descriptor.ViewRowAttributesLayout) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) ASIDocument(de.metas.ui.web.pattribute.ASIDocument) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Example 2 with JSONOptions

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);
    });
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector)

Example 3 with JSONOptions

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));
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions)

Example 4 with JSONOptions

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();
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) DocumentReference(de.metas.ui.web.window.model.DocumentReference) JSONDocumentReference(de.metas.ui.web.window.datatypes.json.JSONDocumentReference) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 5 with JSONOptions

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);
    });
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) Document(de.metas.ui.web.window.model.Document) InvalidDocumentPathException(de.metas.ui.web.window.exceptions.InvalidDocumentPathException)

Aggregations

JSONOptions (de.metas.ui.web.window.datatypes.json.JSONOptions)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 JSONDocumentChangedEvent (de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 Multimap (com.google.common.collect.Multimap)1 BoardCardChangeRequestBuilder (de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder)1 JSONBoard (de.metas.ui.web.board.json.JSONBoard)1 JSONBoardBuilder (de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder)1 JSONBoardCard (de.metas.ui.web.board.json.JSONBoardCard)1 JSONBoardCardAddRequest (de.metas.ui.web.board.json.JSONBoardCardAddRequest)1 JSONBoardCardOrderBy (de.metas.ui.web.board.json.JSONBoardCardOrderBy)1 JSONBoardLane (de.metas.ui.web.board.json.JSONBoardLane)1 JSONNewCardsViewLayout (de.metas.ui.web.board.json.JSONNewCardsViewLayout)1 WebConfig (de.metas.ui.web.config.WebConfig)1 JsonKPI (de.metas.ui.web.dashboard.json.JsonKPI)1 JSONDocumentFilterDescriptor (de.metas.ui.web.document.filter.json.JSONDocumentFilterDescriptor)1 ASIDocument (de.metas.ui.web.pattribute.ASIDocument)1 ASILayout (de.metas.ui.web.pattribute.ASILayout)1