Search in sources :

Example 11 with WindowId

use of de.metas.ui.web.window.datatypes.WindowId 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(ListUtils.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) ListUtils(org.adempiere.util.collections.ListUtils) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) DetailId(de.metas.ui.web.window.descriptor.DetailId) 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 12 with WindowId

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

the class WindowRestController method getDocumentFieldZoomInto.

@ApiOperation("field current value's window layout to zoom into")
@GetMapping("/{windowId}/{documentId}/field/{fieldName}/zoomInto")
public JSONZoomInto getDocumentFieldZoomInto(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("fieldName") final String fieldName) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
    return getDocumentFieldZoomInto(documentPath, fieldName);
}
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) ApiOperation(io.swagger.annotations.ApiOperation)

Example 13 with WindowId

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

the class WindowRestController method processRecord.

/**
 * @task https://github.com/metasfresh/metasfresh/issues/1090
 */
@GetMapping("/{windowId}/{documentId}/processNewRecord")
public int processRecord(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentIdStr) {
    userSession.assertLoggedIn();
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    final IDocumentChangesCollector changesCollector = NullDocumentChangesCollector.instance;
    return Execution.callInNewExecution("window.processTemplate", () -> documentCollection.forDocumentWritable(documentPath, changesCollector, document -> {
        document.saveIfValidAndHasChanges();
        if (document.hasChangesRecursivelly()) {
            throw new AdempiereException("Not saved");
        }
        final int newRecordId = newRecordDescriptorsProvider.getNewRecordDescriptor(document.getEntityDescriptor()).getProcessor().processNewRecordDocument(document);
        return newRecordId;
    }));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebRequest(org.springframework.web.context.request.WebRequest) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) JSONZoomInto(de.metas.ui.web.window.datatypes.json.JSONZoomInto) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) ApiOperation(io.swagger.annotations.ApiOperation) DocumentWebsocketPublisher(de.metas.ui.web.window.events.DocumentWebsocketPublisher) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) JSONDocumentReferencesGroupList(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroupList) DocumentReference(de.metas.ui.web.window.model.DocumentReference) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) PostMapping(org.springframework.web.bind.annotation.PostMapping) ImmutableSet(com.google.common.collect.ImmutableSet) Predicate(java.util.function.Predicate) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) DocumentDescriptor(de.metas.ui.web.window.descriptor.DocumentDescriptor) Set(java.util.Set) ProcessRestController(de.metas.ui.web.process.ProcessRestController) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) UserSession(de.metas.ui.web.session.UserSession) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) MenuTreeRepository(de.metas.ui.web.menu.MenuTreeRepository) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentReferencesService(de.metas.ui.web.window.model.DocumentReferencesService) WebConfig(de.metas.ui.web.config.WebConfig) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ButtonFieldActionDescriptor(de.metas.ui.web.window.descriptor.ButtonFieldActionDescriptor) MenuTree(de.metas.ui.web.menu.MenuTree) InvalidDocumentPathException(de.metas.ui.web.window.exceptions.InvalidDocumentPathException) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) RequestBody(org.springframework.web.bind.annotation.RequestBody) ImmutableList(com.google.common.collect.ImmutableList) DetailId(de.metas.ui.web.window.descriptor.DetailId) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONDocumentReferencesGroup(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroup) NewRecordDescriptorsProvider(de.metas.ui.web.window.descriptor.factory.NewRecordDescriptorsProvider) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) WindowId(de.metas.ui.web.window.datatypes.WindowId) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) HttpStatus(org.springframework.http.HttpStatus) JSONDocumentActionsList(de.metas.ui.web.process.json.JSONDocumentActionsList) DocumentPreconditionsAsContext(de.metas.ui.web.process.DocumentPreconditionsAsContext) AdempiereException(org.adempiere.exceptions.AdempiereException) JSONDocumentReference(de.metas.ui.web.window.datatypes.json.JSONDocumentReference) ResponseEntity(org.springframework.http.ResponseEntity) JSONDocumentLayout(de.metas.ui.web.window.datatypes.json.JSONDocumentLayout) Document(de.metas.ui.web.window.model.Document) WindowId(de.metas.ui.web.window.datatypes.WindowId) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 14 with WindowId

use of de.metas.ui.web.window.datatypes.WindowId 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 DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, tabIdStr, rowIdStr);
    final Set<TableRecordReference> selectedIncludedRecords = ImmutableSet.of();
    return getDocumentActions(documentPath, selectedIncludedRecords, returnDisabled);
}
Also used : 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 15 with WindowId

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

the class WindowRestController method getData.

@GetMapping("/{windowId}/{documentId}/{tabId}/{rowId}")
public List<JSONDocument> getData(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentIdStr, // 
@PathVariable("tabId") final String tabIdStr, // 
@PathVariable("rowId") final String rowIdStr, // 
@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) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, tabIdStr, rowIdStr);
    final List<DocumentQueryOrderBy> orderBys = ImmutableList.of();
    return getData(documentPath, fieldsListStr, advanced, orderBys);
}
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) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

WindowId (de.metas.ui.web.window.datatypes.WindowId)48 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)22 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)13 GetMapping (org.springframework.web.bind.annotation.GetMapping)13 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)9 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)9 List (java.util.List)9 Set (java.util.Set)9 ImmutableList (com.google.common.collect.ImmutableList)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 AdempiereException (org.adempiere.exceptions.AdempiereException)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 NonNull (lombok.NonNull)7 Services (org.adempiere.util.Services)7 LogManager (de.metas.logging.LogManager)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)6 DetailId (de.metas.ui.web.window.descriptor.DetailId)6 Logger (org.slf4j.Logger)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)5