Search in sources :

Example 26 with DocumentPath

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

the class WindowRestController method deleteIncludedDocument.

@DeleteMapping("/{windowId}/{documentId}/{tabId}/{rowId}")
public List<JSONDocument> deleteIncludedDocument(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("tabId") final String tabId, // 
@PathVariable("rowId") final String rowId) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentId, tabId, rowId);
    return deleteDocuments(ImmutableList.of(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) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 27 with DocumentPath

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

the class WindowRestController method getDocumentActions.

@GetMapping("/{windowId}/{documentId}/actions")
public JSONDocumentActionsList getDocumentActions(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @RequestParam(name = "selectedTabId", required = false) final String selectedTabIdStr, @RequestParam(name = "selectedRowIds", required = false) final String selectedRowIdsAsStr, @RequestParam(name = "disabled", defaultValue = "false") final boolean returnDisabled) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath rootDocumentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    final DetailId selectedTabId = DetailId.fromJson(selectedTabIdStr);
    final DocumentIdsSelection selectedRowIds = DocumentIdsSelection.ofCommaSeparatedString(selectedRowIdsAsStr);
    final Set<TableRecordReference> selectedIncludedRecords = selectedRowIds.stream().map(rowId -> rootDocumentPath.createChildPath(selectedTabId, rowId)).map(documentCollection::getTableRecordReference).collect(ImmutableSet.toImmutableSet());
    return getDocumentActions(rootDocumentPath, 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) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) 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 28 with DocumentPath

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

the class WindowRestController method getDocumentFieldZoomInto.

private JSONZoomInto getDocumentFieldZoomInto(final DocumentPath documentPath, final String fieldName) {
    userSession.assertLoggedIn();
    final JSONDocumentPath jsonZoomIntoDocumentPath;
    final DocumentZoomIntoInfo zoomIntoInfo = documentCollection.forDocumentReadonly(documentPath, document -> getDocumentFieldZoomInto(document, fieldName));
    if (zoomIntoInfo == null) {
        throw new EntityNotFoundException("ZoomInto not supported").setParameter("documentPath", documentPath).setParameter("fieldName", fieldName);
    } else if (!zoomIntoInfo.isRecordIdPresent()) {
        final WindowId windowId = documentCollection.getWindowId(zoomIntoInfo);
        jsonZoomIntoDocumentPath = JSONDocumentPath.newWindowRecord(windowId);
    } else {
        final DocumentPath zoomIntoDocumentPath = documentCollection.getDocumentPath(zoomIntoInfo);
        jsonZoomIntoDocumentPath = JSONDocumentPath.ofWindowDocumentPath(zoomIntoDocumentPath);
    }
    return JSONZoomInto.builder().documentPath(jsonZoomIntoDocumentPath).source(JSONDocumentPath.ofWindowDocumentPath(documentPath, fieldName)).build();
}
Also used : DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) 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) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath)

Example 29 with DocumentPath

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

the class WindowRestController method getDocumentFieldTypeahead.

/**
 * Typeahead for included document's field
 */
@GetMapping(value = "/{windowId}/{documentId}/{tabId}/{rowId}/field/{fieldName}/typeahead")
public JSONLookupValuesList getDocumentFieldTypeahead(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("tabId") final String tabId, // 
@PathVariable("rowId") final String rowId, // 
@PathVariable("fieldName") final String fieldName, // 
@RequestParam(name = "query", required = true) final String query) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentId, tabId, rowId);
    return getDocumentFieldTypeahead(documentPath, fieldName, query);
}
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)

Example 30 with DocumentPath

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

the class WindowRestController method getRootDocuments.

@GetMapping("/{windowId}/{documentId}")
public List<JSONDocument> getRootDocuments(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @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 = "noTabs", required = false, defaultValue = "false") final boolean noTabs) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    final JSONDocumentOptions jsonOpts = newJSONDocumentOptions().showOnlyFieldsListStr(fieldsListStr).showAdvancedFields(advanced).doNotFetchIncludedTabs(noTabs).build();
    return getData(documentPath, DocumentQueryOrderByList.EMPTY, jsonOpts);
}
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) JSONDocumentOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentOptions) 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