Search in sources :

Example 31 with DocumentPath

use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.

the class WindowRestController method getIncludedTabRows.

@GetMapping("/{windowId}/{documentId}/{tabId}")
public List<JSONDocument> getIncludedTabRows(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @PathVariable("tabId") final String tabIdStr, @RequestParam(name = "ids", required = false) @ApiParam("comma separated rowIds") final String rowIdsListStr, @RequestParam(name = PARAM_FieldsList, required = false) @ApiParam("comma separated field names") final String fieldsListStr, @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced, @RequestParam(name = "orderBy", required = false) final String orderBysListStr) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentId documentId = DocumentId.of(documentIdStr);
    final DetailId tabId = DetailId.fromJson(tabIdStr);
    final DocumentIdsSelection onlyRowIds = DocumentIdsSelection.ofCommaSeparatedString(rowIdsListStr);
    final DocumentPath documentPath;
    if (onlyRowIds.isEmpty() || onlyRowIds.isAll()) {
        documentPath = DocumentPath.includedDocumentPath(windowId, documentId, tabId);
    } else {
        documentPath = DocumentPath.includedDocumentPath(windowId, documentId, tabId, onlyRowIds);
    }
    final DocumentQueryOrderByList orderBys = DocumentQueryOrderByList.parse(orderBysListStr);
    final JSONDocumentOptions jsonOpts = newJSONDocumentOptions().showOnlyFieldsListStr(fieldsListStr).showAdvancedFields(advanced).build();
    return getData(documentPath, orderBys, jsonOpts);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) DocumentQueryOrderByList(de.metas.ui.web.window.model.DocumentQueryOrderByList) JSONDocumentOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentOptions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 32 with DocumentPath

use of de.metas.ui.web.window.datatypes.DocumentPath 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);
    final JSONDocumentOptions jsonOpts = newJSONDocumentOptions().showAdvancedFields(advanced).build();
    return JSONDocument.ofDocument(documentCopy, jsonOpts);
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) JSONDocumentOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentOptions) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) Document(de.metas.ui.web.window.model.Document) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 33 with DocumentPath

use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.

the class WindowRestController method getIncludedDocumentActions.

@GetMapping("/{windowId}/{documentId}/{tabId}/{rowId}/actions")
public JSONDocumentActionsList getIncludedDocumentActions(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @PathVariable("tabId") final String tabIdStr, @PathVariable("rowId") final String rowIdStr, @RequestParam(name = "disabled", defaultValue = "false") final boolean returnDisabled) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DetailId selectedTabId = DetailId.fromJson(tabIdStr);
    final DocumentPath includedDocumentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, selectedTabId.toJson(), rowIdStr);
    final Set<TableRecordReference> selectedIncludedRecords = ImmutableSet.of();
    return getDocumentActions(includedDocumentPath, selectedTabId, selectedIncludedRecords, returnDisabled, DisplayPlace.SingleDocumentActionsMenu);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) WindowId(de.metas.ui.web.window.datatypes.WindowId) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 34 with DocumentPath

use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.

the class JSONCreateViewRequest method getReferencingDocumentPaths.

public Set<DocumentPath> getReferencingDocumentPaths() {
    if (referencing == null) {
        return ImmutableSet.of();
    }
    final Set<String> documentIds = referencing.getDocumentIds();
    if (documentIds == null || documentIds.isEmpty()) {
        return ImmutableSet.of();
    }
    final WindowId windowId = WindowId.fromJson(referencing.getDocumentType());
    final String tabIdStr = referencing.getTabId();
    if (tabIdStr == null) {
        return documentIds.stream().map(id -> DocumentPath.rootDocumentPath(windowId, id)).collect(ImmutableSet.toImmutableSet());
    } else {
        final DocumentId documentId = DocumentId.of(CollectionUtils.singleElement(documentIds));
        final DetailId tabId = DetailId.fromJson(tabIdStr);
        final Set<String> rowIds = referencing.getRowIds();
        return rowIds.stream().map(DocumentId::of).map(rowId -> DocumentPath.includedDocumentPath(windowId, documentId, tabId, rowId)).collect(ImmutableSet.toImmutableSet());
    }
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ImmutableSet(com.google.common.collect.ImmutableSet) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ViewProfileId(de.metas.ui.web.view.ViewProfileId) Set(java.util.Set) Visibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility) WindowId(de.metas.ui.web.window.datatypes.WindowId) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) DetailId(de.metas.ui.web.window.descriptor.DetailId) CollectionUtils(de.metas.util.collections.CollectionUtils) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) Preconditions(com.google.common.base.Preconditions) JSONDocumentFilter(de.metas.ui.web.document.filter.json.JSONDocumentFilter) DetailId(de.metas.ui.web.window.descriptor.DetailId) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 35 with DocumentPath

use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.

the class WindowRestController method getDocumentChangeLog.

@GetMapping("/{windowId}/{documentId}/changeLog")
public JSONDocumentChangeLog getDocumentChangeLog(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    return getDocumentChangeLog(documentPath);
}
Also used : 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) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)65 WindowId (de.metas.ui.web.window.datatypes.WindowId)29 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)22 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)20 GetMapping (org.springframework.web.bind.annotation.GetMapping)14 List (java.util.List)13 ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 DetailId (de.metas.ui.web.window.descriptor.DetailId)12 Set (java.util.Set)11 NonNull (lombok.NonNull)10 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)10 AdempiereException (org.adempiere.exceptions.AdempiereException)9 PostMapping (org.springframework.web.bind.annotation.PostMapping)9 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)7 ViewId (de.metas.ui.web.view.ViewId)6 Services (de.metas.util.Services)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)5