Search in sources :

Example 16 with DocumentId

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

the class DocumentWebsocketPublisher method collectFrom.

private static final void collectFrom(final JSONDocumentChangedWebSocketEventCollector collector, final JSONDocument event) {
    final WindowId windowId = event.getWindowId();
    if (windowId == null) {
        return;
    }
    // Included document => nothing to publish about it
    if (event.getTabId() != null) {
        return;
    }
    final DocumentId documentId = event.getId();
    event.getIncludedTabsInfos().forEach(tabInfo -> collector.mergeFrom(windowId, documentId, tabInfo));
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 17 with DocumentId

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

the class JSONDocumentChangedWebSocketEvent method rootDocument.

public static JSONDocumentChangedWebSocketEvent rootDocument(final WindowId windowId, final DocumentId documentId) {
    final String tabId = null;
    final DocumentId rowId = null;
    final JSONDocumentChangedWebSocketEvent event = new JSONDocumentChangedWebSocketEvent(windowId, documentId, tabId, rowId);
    return event;
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ToString(lombok.ToString)

Example 18 with DocumentId

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

the class ProcessRestController method getInstance.

@RequestMapping(value = "/{processId}/{pinstanceId}", method = RequestMethod.GET)
public JSONProcessInstance getInstance(@PathVariable("processId") final String processIdStr, @PathVariable("pinstanceId") final String pinstanceIdStr) {
    userSession.assertLoggedIn();
    final ProcessId processId = ProcessId.fromJson(processIdStr);
    final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
    final IProcessInstancesRepository instancesRepository = getRepository(processId);
    return instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> JSONProcessInstance.of(processInstance, newJSONOptions()));
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with DocumentId

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

the class ProcessRestController method getParameterTypeahead.

@RequestMapping(value = "/{processId}/{pinstanceId}/field/{parameterName}/typeahead", method = RequestMethod.GET)
public JSONLookupValuesList getParameterTypeahead(// 
@PathVariable("processId") final String processIdStr, // 
@PathVariable("pinstanceId") final String pinstanceIdStr, // 
@PathVariable("parameterName") final String parameterName, // 
@RequestParam(name = "query", required = true) final String query) {
    userSession.assertLoggedIn();
    final ProcessId processId = ProcessId.fromJson(processIdStr);
    final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
    final IProcessInstancesRepository instancesRepository = getRepository(processId);
    return instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> processInstance.getParameterLookupValuesForQuery(parameterName, query)).transform(JSONLookupValuesList::ofLookupValuesList);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebRequest(org.springframework.web.context.request.WebRequest) Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) OpenReportAction(de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) IView(de.metas.ui.web.view.IView) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) Util(org.compiere.util.Util) HttpHeaders(org.springframework.http.HttpHeaders) NonNull(lombok.NonNull) Collection(java.util.Collection) MediaType(org.springframework.http.MediaType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) UserSession(de.metas.ui.web.session.UserSession) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) JSONProcessLayout(de.metas.ui.web.process.json.JSONProcessLayout) IViewsRepository(de.metas.ui.web.view.IViewsRepository) LogManager(de.metas.logging.LogManager) JSONProcessInstanceResult(de.metas.ui.web.process.json.JSONProcessInstanceResult) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WebConfig(de.metas.ui.web.config.WebConfig) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Execution(de.metas.ui.web.window.controller.Execution) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONCreateProcessInstanceRequest(de.metas.ui.web.process.json.JSONCreateProcessInstanceRequest) JSONProcessInstance(de.metas.ui.web.process.json.JSONProcessInstance) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) Logger(org.slf4j.Logger) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) ApplicationContext(org.springframework.context.ApplicationContext) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) HttpStatus(org.springframework.http.HttpStatus) Check(org.adempiere.util.Check) ResponseEntity(org.springframework.http.ResponseEntity) ViewId(de.metas.ui.web.view.ViewId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with DocumentId

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

the class ProcessRestController method startProcess.

@RequestMapping(value = "/{processId}/{pinstanceId}/start", method = RequestMethod.GET)
public JSONProcessInstanceResult startProcess(// 
@PathVariable("processId") final String processIdStr, // 
@PathVariable("pinstanceId") final String pinstanceIdStr) {
    userSession.assertLoggedIn();
    final ProcessId processId = ProcessId.fromJson(processIdStr);
    final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
    final IProcessInstancesRepository instancesRepository = getRepository(processId);
    return Execution.prepareNewExecution().outOfTransaction().execute(() -> {
        return instancesRepository.forProcessInstanceWritable(pinstanceId, NullDocumentChangesCollector.instance, processInstance -> {
            final ProcessInstanceResult result = processInstance.startProcess(ProcessExecutionContext.builder().ctx(Env.getCtx()).adLanguage(userSession.getAD_Language()).viewsRepo(viewsRepo).documentsCollection(documentsCollection).build());
            return JSONProcessInstanceResult.of(result);
        });
    });
}
Also used : JSONProcessInstanceResult(de.metas.ui.web.process.json.JSONProcessInstanceResult) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DocumentId (de.metas.ui.web.window.datatypes.DocumentId)99 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)18 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)14 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 AdempiereException (org.adempiere.exceptions.AdempiereException)11 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)9 ArrayList (java.util.ArrayList)9 Set (java.util.Set)9 NonNull (lombok.NonNull)9 Test (org.junit.Test)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 UserSession (de.metas.ui.web.session.UserSession)8 ViewId (de.metas.ui.web.view.ViewId)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)8 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8