Search in sources :

Example 1 with DisplayPlace

use of de.metas.process.RelatedProcessDescriptor.DisplayPlace in project metasfresh-webui-api by metasfresh.

the class ViewRestController method getDocumentQuickActions.

@GetMapping("/{viewId}/quickActions")
public JSONDocumentActionsList getDocumentQuickActions(@PathVariable(PARAM_WindowId) final String windowId, @PathVariable(PARAM_ViewId) final String viewIdStr, @RequestParam(name = "selectedIds", required = false) @ApiParam("comma separated IDs") final String selectedIdsListStr, @RequestParam(name = "parentViewId", required = false) final String parentViewIdStr, @RequestParam(name = "parentViewSelectedIds", required = false) @ApiParam("comma separated IDs") final String parentViewSelectedIdsListStr, @RequestParam(name = "childViewId", required = false) final String childViewIdStr, @RequestParam(name = "childViewSelectedIds", required = false) @ApiParam("comma separated IDs") final String childViewSelectedIdsListStr, @RequestParam(name = "viewProfileId", required = false) final String viewProfileIdStr, @RequestParam(name = "all", required = false) final boolean all) {
    userSession.assertLoggedIn();
    final WebuiPreconditionsContext preconditionsContext = newPreconditionsContextBuilder().windowId(windowId).viewIdString(viewIdStr).viewProfileIdStr(viewProfileIdStr).selectedIdsList(selectedIdsListStr).parentViewId(parentViewIdStr).parentViewSelectedIdsList(parentViewSelectedIdsListStr).childViewId(childViewIdStr).childViewSelectedIdsList(childViewSelectedIdsListStr).displayPlace(DisplayPlace.ViewQuickActions).build();
    return processRestController.streamDocumentRelatedProcesses(preconditionsContext).filter(// shall be already filtered out, but just to make sure
    descriptor -> descriptor.isDisplayedOn(preconditionsContext.getDisplayPlace())).filter(// only those which are enabled or not silent
    descriptor -> all || descriptor.isEnabledOrNotSilent()).collect(JSONDocumentActionsList.collect(newJSONOptions()));
}
Also used : MimeType(org.compiere.util.MimeType) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) WebRequest(org.springframework.web.context.request.WebRequest) ApiParam(io.swagger.annotations.ApiParam) JSONZoomInto(de.metas.ui.web.window.datatypes.json.JSONZoomInto) Evaluatee(org.compiere.util.Evaluatee) InputStreamResource(org.springframework.core.io.InputStreamResource) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) JSONViewLayout(de.metas.ui.web.view.json.JSONViewLayout) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ExcelFormat(de.metas.impexp.excel.ExcelFormat) Resource(org.springframework.core.io.Resource) PostMapping(org.springframework.web.bind.annotation.PostMapping) WindowRestController(de.metas.ui.web.window.controller.WindowRestController) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) HttpHeaders(org.springframework.http.HttpHeaders) NonNull(lombok.NonNull) MediaType(org.springframework.http.MediaType) ProcessRestController(de.metas.ui.web.process.ProcessRestController) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) Objects(java.util.Objects) UserSession(de.metas.ui.web.session.UserSession) JSONViewRow(de.metas.ui.web.view.json.JSONViewRow) List(java.util.List) Builder(lombok.Builder) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WebConfig(de.metas.ui.web.config.WebConfig) ViewAsPreconditionsContext(de.metas.ui.web.process.ViewAsPreconditionsContext) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONViewProfilesList(de.metas.ui.web.view.json.JSONViewProfilesList) ImmutableList(com.google.common.collect.ImmutableList) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Evaluatees(org.compiere.util.Evaluatees) FileOutputStream(java.io.FileOutputStream) WindowId(de.metas.ui.web.window.datatypes.WindowId) FileInputStream(java.io.FileInputStream) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) File(java.io.File) HttpStatus(org.springframework.http.HttpStatus) JSONDocumentActionsList(de.metas.ui.web.process.json.JSONDocumentActionsList) JSONCreateViewRequest(de.metas.ui.web.view.json.JSONCreateViewRequest) AdempiereException(org.adempiere.exceptions.AdempiereException) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) ResponseEntity(org.springframework.http.ResponseEntity) ExcelFormats(de.metas.impexp.excel.ExcelFormats) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with DisplayPlace

use of de.metas.process.RelatedProcessDescriptor.DisplayPlace in project metasfresh-webui-api by metasfresh.

the class WebuiAccountingConfig method registerRepostProcessForSingleDocuments.

private void registerRepostProcessForSingleDocuments() {
    final IADProcessDAO adProcessesRepo = Services.get(IADProcessDAO.class);
    final IADTableDAO adTablesRepo = Services.get(IADTableDAO.class);
    final AdProcessId repostProcessId = adProcessesRepo.retrieveProcessIdByClassIfUnique(WEBUI_Fact_Acct_Repost_SingleDocument.class);
    if (repostProcessId == null) {
        logger.warn("No AD_Process_ID found for {}", WEBUI_Fact_Acct_Repost_SingleDocument.class);
        return;
    }
    // 
    final List<String> linkToTableNames = new ArrayList<>();
    linkToTableNames.addAll(acctDocRegistry.getDocTableNames());
    linkToTableNames.add(WEBUI_Fact_Acct_Repost_ViewRows.TABLENAME_RV_UnPosted);
    // 
    // Link Repost process to all accountable documents
    linkToTableNames.stream().map(adTablesRepo::retrieveTableId).filter(adTableId -> adTableId > 0).forEach(adTableId -> adProcessesRepo.registerTableProcess(RelatedProcessDescriptor.builder().processId(repostProcessId).tableId(adTableId).anyWindow().displayPlace(DisplayPlace.SingleDocumentActionsMenu).build()));
    logger.info("Registered {} ({}) to {} tables", WEBUI_Fact_Acct_Repost_SingleDocument.class.getName(), repostProcessId, linkToTableNames.size());
}
Also used : LogManager(de.metas.logging.LogManager) IADProcessDAO(de.metas.process.IADProcessDAO) Logger(org.slf4j.Logger) DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) WEBUI_Fact_Acct_Repost_ViewRows(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_ViewRows) ArrayList(java.util.ArrayList) Services(de.metas.util.Services) List(java.util.List) Component(org.springframework.stereotype.Component) AcctDocRegistry(de.metas.acct.doc.AcctDocRegistry) AdProcessId(de.metas.process.AdProcessId) PostConstruct(javax.annotation.PostConstruct) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) WEBUI_Fact_Acct_Repost_SingleDocument(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_SingleDocument) WEBUI_Fact_Acct_Repost_SingleDocument(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_SingleDocument) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) AdProcessId(de.metas.process.AdProcessId) ArrayList(java.util.ArrayList) IADProcessDAO(de.metas.process.IADProcessDAO)

Example 3 with DisplayPlace

use of de.metas.process.RelatedProcessDescriptor.DisplayPlace in project metasfresh-webui-api by metasfresh.

the class WebuiAccountingConfig method registerRepostProcessForViewRows.

private void registerRepostProcessForViewRows() {
    final IADProcessDAO adProcessesRepo = Services.get(IADProcessDAO.class);
    final IADTableDAO adTablesRepo = Services.get(IADTableDAO.class);
    final AdProcessId repostProcessId = adProcessesRepo.retrieveProcessIdByClassIfUnique(WEBUI_Fact_Acct_Repost_ViewRows.class);
    if (repostProcessId == null) {
        logger.warn("No AD_Process_ID found for {}", WEBUI_Fact_Acct_Repost_ViewRows.class);
        return;
    }
    // 
    final List<String> linkToTableNames = new ArrayList<>();
    linkToTableNames.addAll(acctDocRegistry.getDocTableNames());
    linkToTableNames.add(WEBUI_Fact_Acct_Repost_ViewRows.TABLENAME_RV_UnPosted);
    // 
    // Link Repost process to all accountable documents
    linkToTableNames.stream().map(adTablesRepo::retrieveTableId).filter(adTableId -> adTableId > 0).forEach(adTableId -> adProcessesRepo.registerTableProcess(RelatedProcessDescriptor.builder().processId(repostProcessId).tableId(adTableId).anyWindow().displayPlace(DisplayPlace.ViewQuickActions).displayPlace(DisplayPlace.ViewActionsMenu).build()));
    logger.info("Registered {} ({}) to {} tables", WEBUI_Fact_Acct_Repost_ViewRows.class.getName(), repostProcessId, linkToTableNames.size());
}
Also used : LogManager(de.metas.logging.LogManager) IADProcessDAO(de.metas.process.IADProcessDAO) Logger(org.slf4j.Logger) DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) RelatedProcessDescriptor(de.metas.process.RelatedProcessDescriptor) WEBUI_Fact_Acct_Repost_ViewRows(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_ViewRows) ArrayList(java.util.ArrayList) Services(de.metas.util.Services) List(java.util.List) Component(org.springframework.stereotype.Component) AcctDocRegistry(de.metas.acct.doc.AcctDocRegistry) AdProcessId(de.metas.process.AdProcessId) PostConstruct(javax.annotation.PostConstruct) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) WEBUI_Fact_Acct_Repost_SingleDocument(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_SingleDocument) WEBUI_Fact_Acct_Repost_ViewRows(de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_ViewRows) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) AdProcessId(de.metas.process.AdProcessId) ArrayList(java.util.ArrayList) IADProcessDAO(de.metas.process.IADProcessDAO)

Example 4 with DisplayPlace

use of de.metas.process.RelatedProcessDescriptor.DisplayPlace in project metasfresh-webui-api by metasfresh.

the class ViewRestController method getDocumentActions.

@GetMapping("/{viewId}/actions")
public JSONDocumentActionsList getDocumentActions(@PathVariable(PARAM_WindowId) final String windowId, @PathVariable(PARAM_ViewId) final String viewIdStr, @RequestParam(name = "selectedIds", required = false) @ApiParam("comma separated IDs") final String selectedIdsListStr, @RequestParam(name = "parentViewId", required = false) final String parentViewIdStr, @RequestParam(name = "parentViewSelectedIds", required = false) @ApiParam("comma separated IDs") final String parentViewSelectedIdsListStr, @RequestParam(name = "childViewId", required = false) final String childViewIdStr, @RequestParam(name = "childViewSelectedIds", required = false) @ApiParam("comma separated IDs") final String childViewSelectedIdsListStr, @RequestParam(name = "all", required = false) final boolean all) {
    userSession.assertLoggedIn();
    final WebuiPreconditionsContext preconditionsContext = newPreconditionsContextBuilder().windowId(windowId).viewIdString(viewIdStr).selectedIdsList(selectedIdsListStr).parentViewId(parentViewIdStr).parentViewSelectedIdsList(parentViewSelectedIdsListStr).childViewId(childViewIdStr).childViewSelectedIdsList(childViewSelectedIdsListStr).displayPlace(DisplayPlace.ViewActionsMenu).build();
    return processRestController.streamDocumentRelatedProcesses(preconditionsContext).filter(// shall be already filtered out, but just to make sure
    descriptor -> descriptor.isDisplayedOn(preconditionsContext.getDisplayPlace())).filter(// only those which are enabled and not internally rejected
    descriptor -> all || descriptor.isEnabled()).collect(JSONDocumentActionsList.collect(newJSONOptions()));
}
Also used : MimeType(org.compiere.util.MimeType) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) DisplayPlace(de.metas.process.RelatedProcessDescriptor.DisplayPlace) WebRequest(org.springframework.web.context.request.WebRequest) ApiParam(io.swagger.annotations.ApiParam) JSONZoomInto(de.metas.ui.web.window.datatypes.json.JSONZoomInto) Evaluatee(org.compiere.util.Evaluatee) InputStreamResource(org.springframework.core.io.InputStreamResource) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) JSONViewLayout(de.metas.ui.web.view.json.JSONViewLayout) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) ExcelFormat(de.metas.impexp.excel.ExcelFormat) Resource(org.springframework.core.io.Resource) PostMapping(org.springframework.web.bind.annotation.PostMapping) WindowRestController(de.metas.ui.web.window.controller.WindowRestController) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) LookupDataSourceContext(de.metas.ui.web.window.model.lookup.LookupDataSourceContext) HttpHeaders(org.springframework.http.HttpHeaders) NonNull(lombok.NonNull) MediaType(org.springframework.http.MediaType) ProcessRestController(de.metas.ui.web.process.ProcessRestController) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) Objects(java.util.Objects) UserSession(de.metas.ui.web.session.UserSession) JSONViewRow(de.metas.ui.web.view.json.JSONViewRow) List(java.util.List) Builder(lombok.Builder) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WebConfig(de.metas.ui.web.config.WebConfig) ViewAsPreconditionsContext(de.metas.ui.web.process.ViewAsPreconditionsContext) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONViewProfilesList(de.metas.ui.web.view.json.JSONViewProfilesList) ImmutableList(com.google.common.collect.ImmutableList) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Evaluatees(org.compiere.util.Evaluatees) FileOutputStream(java.io.FileOutputStream) WindowId(de.metas.ui.web.window.datatypes.WindowId) FileInputStream(java.io.FileInputStream) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) File(java.io.File) HttpStatus(org.springframework.http.HttpStatus) JSONDocumentActionsList(de.metas.ui.web.process.json.JSONDocumentActionsList) JSONCreateViewRequest(de.metas.ui.web.view.json.JSONCreateViewRequest) AdempiereException(org.adempiere.exceptions.AdempiereException) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) ResponseEntity(org.springframework.http.ResponseEntity) ExcelFormats(de.metas.impexp.excel.ExcelFormats) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

DisplayPlace (de.metas.process.RelatedProcessDescriptor.DisplayPlace)4 List (java.util.List)4 ImmutableList (com.google.common.collect.ImmutableList)2 AcctDocRegistry (de.metas.acct.doc.AcctDocRegistry)2 ExcelFormat (de.metas.impexp.excel.ExcelFormat)2 ExcelFormats (de.metas.impexp.excel.ExcelFormats)2 LogManager (de.metas.logging.LogManager)2 AdProcessId (de.metas.process.AdProcessId)2 IADProcessDAO (de.metas.process.IADProcessDAO)2 RelatedProcessDescriptor (de.metas.process.RelatedProcessDescriptor)2 WEBUI_Fact_Acct_Repost_SingleDocument (de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_SingleDocument)2 WEBUI_Fact_Acct_Repost_ViewRows (de.metas.ui.web.accounting.process.WEBUI_Fact_Acct_Repost_ViewRows)2 ETagResponseEntityBuilder (de.metas.ui.web.cache.ETagResponseEntityBuilder)2 WebConfig (de.metas.ui.web.config.WebConfig)2 ProcessRestController (de.metas.ui.web.process.ProcessRestController)2 ViewAsPreconditionsContext (de.metas.ui.web.process.ViewAsPreconditionsContext)2 WebuiPreconditionsContext (de.metas.ui.web.process.WebuiPreconditionsContext)2 JSONDocumentActionsList (de.metas.ui.web.process.json.JSONDocumentActionsList)2 UserSession (de.metas.ui.web.session.UserSession)2 ViewLayout (de.metas.ui.web.view.descriptor.ViewLayout)2