Search in sources :

Example 1 with JSONProcessInstanceResult

use of de.metas.ui.web.process.json.JSONProcessInstanceResult 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

JSONProcessInstanceResult (de.metas.ui.web.process.json.JSONProcessInstanceResult)1 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1