当前位置: 首页>>代码示例>>Java>>正文


Java ProcessInstance类代码示例

本文整理汇总了Java中org.kie.api.runtime.process.ProcessInstance的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstance类的具体用法?Java ProcessInstance怎么用?Java ProcessInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProcessInstance类属于org.kie.api.runtime.process包,在下文中一共展示了ProcessInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getState

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Override
public ProcessInstanceService getState(Handler<AsyncResult<ProcessState>> handler) {

  int state = instance.getState();

  switch (state) {
    case ProcessInstance.STATE_ABORTED:
      handler.handle(Future.succeededFuture(ProcessState.ABORTED));
      break;
    case ProcessInstance.STATE_ACTIVE:
      handler.handle(Future.succeededFuture(ProcessState.ACTIVE));
      break;
    case ProcessInstance.STATE_COMPLETED:
      handler.handle(Future.succeededFuture(ProcessState.COMPLETED));
      break;
    case ProcessInstance.STATE_PENDING:
      handler.handle(Future.succeededFuture(ProcessState.PENDING));
      break;
    case ProcessInstance.STATE_SUSPENDED:
      handler.handle(Future.succeededFuture(ProcessState.SUSPENDED));
      break;
  }

  return this;
}
 
开发者ID:diabolicallabs,项目名称:vertx-process-manager,代码行数:26,代码来源:ProcessInstanceServiceImpl.java

示例2: getOpenWorkflows

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
public List<WorkflowSummaryDto> getOpenWorkflows(int first, int pageSize, String user) {
	List<Integer> states = new ArrayList<Integer>();
	states.add(ProcessInstance.STATE_ACTIVE);
	states.add(ProcessInstance.STATE_PENDING);
	states.add(ProcessInstance.STATE_SUSPENDED);

	Set<Long> processInstanceIds = new HashSet<Long>();
	for (ProcessInstanceDesc processInstanceDesc : getProcessInstances(first, pageSize, states, user)) {
		processInstanceIds.add(processInstanceDesc.getId());
	}

	if (!processInstanceIds.isEmpty()) {
		return dtoService.listOpenWorkflows(processInstanceIds);
	}
	return null;
}
 
开发者ID:awizen,项目名称:gangehi,代码行数:17,代码来源:ScheduleService.java

示例3: doTest

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Test
public void doTest() throws Exception {

	TaskService service = engine.getTaskService();
	ProcessInstance pi = engine.getKieSession().startProcess(PROCESS_ID);
	List<TaskSummary> tasks = service.getTasksAssignedAsPotentialOwner(USR, "en-UK");
	System.out.println("Process created: " + pi.getId());
	System.out.println("Number of tasks: " + tasks.size());
	long taskId = 0l;
	for (TaskSummary taskSummary : tasks) {
		if (taskSummary.getProcessInstanceId() == pi.getId()) {
			taskId = taskSummary.getId();
		}
	}
	if (taskId != 0l) {
		System.out.println("Found task: " + taskId);
		service.claim(taskId, USR);
		service.start(taskId, USR);
		service.complete(taskId, USR, getParameters());
	}
}
 
开发者ID:jesuino,项目名称:bpms6-examples,代码行数:22,代码来源:TaskCompleteTest.java

示例4: testSingleStreamProcess

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Test
public void testSingleStreamProcess() throws Exception {

    CamelHandler handler = new CamelHandler(new GenericURIMapper("stream"), new RequestPayloadMapper("payload"), new ResponsePayloadMapper(), camelContext);
    kieSession.getWorkItemManager().registerWorkItemHandler("CamelStream", handler);

    // Write into the file using Camel stream
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("payloadVar", TEST_DATA);
    params.put("pathVar", "file");
    params.put("fileNameVar", testFile.getAbsolutePath());

    ProcessInstance pi = kieSession.startProcess("camelStreamProcess", params);
    ProcessInstance result = kieSession.getProcessInstance(pi.getId());
    assertNull(result);

    // Verify the output file exists and has correct content
    assertTrue(testFile.exists());
    String resultText = FileUtils.readFileToString(testFile);
    assertTrue(resultText.contains(TEST_DATA));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:22,代码来源:CamelStreamTest.java

示例5: testSingleFileProcess

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
/**
 * Test with entire BPMN process.
 * @throws java.io.IOException
 */
@Test
public void testSingleFileProcess() throws IOException {
    final String testData = "test-data";

    CamelHandler handler = CamelHandlerFactory.fileHandler();
    kieSession.getWorkItemManager().registerWorkItemHandler("CamelFile", handler);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("payloadVar", testData);
    params.put("pathVar", tempDir.getAbsolutePath());
    params.put("fileNameVar", testFile.getName());

    ProcessInstance pi = kieSession.startProcess("camelFileProcess", params);

    ProcessInstance result = kieSession.getProcessInstance(pi.getId());
    assertNull(result);

    assertTrue(testFile.exists());

    String resultText = FileUtils.readFileToString(testFile);
    assertEquals(testData,resultText);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:27,代码来源:CamelFileTest.java

示例6: unmarshallProcessInstances

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
private List<ProcessInstance> unmarshallProcessInstances(byte [] marshalledSessionByteArray) throws Exception { 
    // Setup env/context/stream
    Environment env = EnvironmentFactory.newEnvironment();
    ByteArrayInputStream bais = new ByteArrayInputStream(marshalledSessionByteArray);
    MarshallerReaderContext context = new MarshallerReaderContext(bais, null, null, null, ProtobufMarshaller.TIMER_READERS, env);

    // Unmarshall
    ProcessMarshaller processMarshaller = new ProtobufProcessMarshaller();
    List<ProcessInstance> processInstanceList = null;
    try { 
        processInstanceList = processMarshaller.readProcessInstances(context);
    }
    catch( Exception e ) { 
        e.printStackTrace();
        throw e;
    }
    
    context.close();
    
    return processInstanceList;
}
 
开发者ID:mrietveld,项目名称:gimcrack,代码行数:22,代码来源:KieGimcrack.java

示例7: startProcess

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
/**
    * Starts up a new ProcessInstance with the given deploymentId and
    * ProcessId. The parameters Map is set into the context of the workflow.
    *
    * @param deploymentId
    *            the deployment id
    * @param processId
    *            the process id
    * @param parameters
    *            the parameters
    * @return the long
    * @throws Exception
    *             the exception
    */
   public long startProcess(String deploymentId, String processId, Map<String, Object> parameters)
		throws Exception {

	long processInstanceId = -1;
	try {
		KieSrampUtil kieSrampUtil = new KieSrampUtil();
		RuntimeManager runtimeManager = kieSrampUtil.getRuntimeManager(processEngineService, deploymentId);
		RuntimeEngine runtime = runtimeManager.getRuntimeEngine(EmptyContext.get());
		KieSession ksession = runtime.getKieSession();
		// start a new process instance
		ProcessInstance processInstance = ksession.startProcess(processId,
				parameters);
		processInstanceId = processInstance.getId();
		logger.info(Messages.i18n.format("ProcessBean.Started", processInstanceId)); //$NON-NLS-1$

	} catch (Exception e) {
		e.printStackTrace();

		throw e;
	}
	return processInstanceId;
}
 
开发者ID:Governance,项目名称:dtgov,代码行数:37,代码来源:ProcessBean.java

示例8: afterProcessCompleted

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Override
public void afterProcessCompleted(ProcessCompletedEvent processCompletedEvent) {

  ProcessInstance instance = processCompletedEvent.getProcessInstance();
  logger.debug("Completed {0} with id {1}", instance.getProcessName(), instance.getId());

  Long id = processCompletedEvent.getProcessInstance().getId();
  vertx.eventBus().send("kie.process.instance." + id + ".complete", "Complete");
}
 
开发者ID:diabolicallabs,项目名称:vertx-process-manager,代码行数:10,代码来源:VertxProcessEventListener.java

示例9: getClosedWorkflows

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
public List<ClosedWorkflowSummaryDto> getClosedWorkflows(int first, int pageSize, String initiator) {
	List<Integer> states = new ArrayList<Integer>();
	states.add(ProcessInstance.STATE_ABORTED);
	states.add(ProcessInstance.STATE_COMPLETED);

	Set<Long> processInstanceIds = new HashSet<Long>();
	for (ProcessInstanceDesc processInstanceDesc : getProcessInstances(first, pageSize, states, initiator)) {
		processInstanceIds.add(processInstanceDesc.getId());
	}

	if (!processInstanceIds.isEmpty()) {
		return dtoService.listClosedWorkflows(processInstanceIds);
	}
	return null;
}
 
开发者ID:awizen,项目名称:gangehi,代码行数:16,代码来源:ScheduleService.java

示例10: getProcessSummary

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
private String getProcessSummary(ProcessInstanceLog pi) {
	long piid = pi.getProcessInstanceId();
	String employee = getVariableValue(piid, P_EMPLOYEE);
	String result = getVariableValue(piid, P_RESULT);
	String status = "";
	switch (pi.getStatus()) {
	case ProcessInstance.STATE_ABORTED:
		status = "aborted";
		break;
	case ProcessInstance.STATE_ACTIVE:
		status = "active";
		break;
	case ProcessInstance.STATE_COMPLETED:
		status = "completed";
		break;
	case ProcessInstance.STATE_PENDING:
		status = "pending";
		break;
	case ProcessInstance.STATE_SUSPENDED:
		status = "suspended";
		break;
	default:
		status = "unknown";
		break;
	}
	if (Objects.isNull(result))
		result = "reward still waiting for approval";
	String summary = "Reward process for employee '%s' is %s and result is '%s'.";
	return String.format(summary, employee, status, result);
}
 
开发者ID:jesuino,项目名称:jbpm-rewards-client,代码行数:31,代码来源:RewardService.java

示例11: getProcessInstanceId

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
private Long getProcessInstanceId(CorrelationKey correlationKey, KnowledgeRuntimeEngine session) {
    if (correlationKey != null) {
        ProcessInstance processInstance = ((CorrelationAwareProcessRuntime)session.getKieSession()).getProcessInstance(correlationKey);
        if (processInstance != null) {
            return Long.valueOf(processInstance.getId());
        }
    }
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:10,代码来源:BPMExchangeHandler.java

示例12: getProcessInstanceVariables

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
private Map<String, Object> getProcessInstanceVariables(ProcessInstance processInstance) {
    Map<String, Object> processInstanceVariables = new HashMap<String, Object>();
    if (processInstance instanceof WorkflowProcessInstanceImpl) {
        Map<String, Object> var = ((WorkflowProcessInstanceImpl)processInstance).getVariables();
        if (var != null) {
            processInstanceVariables.putAll(var);
        }
    }
    return processInstanceVariables;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:BPMExchangeHandler.java

示例13: requestProcessInstanceCreationToServer

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Override
public void requestProcessInstanceCreationToServer(ProcessInstanceCreationRequestI instanceRequest) throws RemoteException, DatastoreException {
	ProcessInstance newInstance = null;
	try
    {
        KieSession session = AppContext.getService(RemoteWfEngine.class).getRemoteEngine().getKieSession();
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("component_id", instanceRequest.getComponentId());
        params.put("component_name", instanceRequest.getComponentName());
        params.put("created_by", instanceRequest.getUserId());
        params.putAll(instanceRequest.getVariables());
        if (instanceRequest.getParams() != null) {
            params.putAll(instanceRequest.getParams());
        }
        newInstance = session.startProcess(instanceRequest.getProcessName(), params);
        procApi.updateRequestStatus(instanceRequest.getId(),
                ProcessInstanceCreationRequestI.RequestStatus.CREATED,
                "Instance created on KIE Server: " + AppContext.getAppConfiguration().getCurrentWorkflowServerUrl().toString(), newInstance.getId());
    }
    catch (RuntimeException e)
        {
            procApi.updateRequestStatus(instanceRequest.getId(),
                    ProcessInstanceCreationRequestI.RequestStatus.REJECTED,
                    "Instance rejected by KIE Server: " + AppContext.getAppConfiguration().getCurrentWorkflowServerUrl().toString() + " - " + e.getMessage(), newInstance != null ? newInstance.getId() : 0);
            throw new RemoteException("Server error", e);
    }
}
 
开发者ID:Apelon-VA,项目名称:ISAAC,代码行数:28,代码来源:LocalWfEngine.java

示例14: testSingleXSLTProcess

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
@Test
public void testSingleXSLTProcess() throws IOException {

    // Load input example into the string
    String inputXML = IOUtils.toString(this.getClass().getClassLoader().getResourceAsStream(XML_FILE));
    // Copy XSL file into the temp directory
    FileUtils.copyInputStreamToFile(this.getClass().getClassLoader().getResourceAsStream(XSL_FILE), xslFile);

    Set<String> headers = new HashSet<String>();
    headers.add(HEADER_KEY_XSLT_OUTPUT_FILE); // header under this key defines output files
    CamelHandler handler = new CamelHandler(new XSLTURIMapper(), new RequestPayloadMapper("payload", headers));
    kieSession.getWorkItemManager().registerWorkItemHandler("CamelXSLT", handler);

    // Run XSLT transformation
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("templateNameVar", "file:///" + xslFile.getAbsolutePath());
    params.put("payloadVar", inputXML);
    params.put("outputFileVar", outputFile.getAbsolutePath());
    params.put("outputVar", "file");

    ProcessInstance pi = kieSession.startProcess("camelXSLTProcess", params);
    ProcessInstance result = kieSession.getProcessInstance(pi.getId());

    // Verify the output file exists and was successfully processed by XSLT transformations
    assertTrue(outputFile.exists());
    // After the running of XSLT transformation, the output file should contain TRANSFORMED_ELEMENT
    String outputXML = FileUtils.readFileToString(outputFile,"UTF-8");
    assertTrue(outputXML.contains(TRANSFORMED_ELEMENT));
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:30,代码来源:CamelXSLTTest.java

示例15: testSingleFileProcess

import org.kie.api.runtime.process.ProcessInstance; //导入依赖的package包/类
/** Test with entire BPMN process. */
@Test
public void testSingleFileProcess() throws IOException {
    final String testData = "test-data";

    CamelHandler handler = CamelHandlerFactory.fileHandler();

    KieHelper kieHelper = new KieHelper();
    kieHelper.addResource(new ClassPathResource(PROCESS_DEFINITION, getClass()), ResourceType.BPMN2);
    KieBase kbase = kieHelper.build();
    KieSession kieSession = kbase.newKieSession();

    kieSession.getWorkItemManager().registerWorkItemHandler("CamelFile", handler);

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("payloadVar", testData);
    params.put("pathVar", tempDir.getAbsolutePath());
    params.put("fileNameVar", testFile.getName());

    ProcessInstance pi = kieSession.startProcess("camelFileProcess", params);

    ProcessInstance result = kieSession.getProcessInstance(pi.getId());
    Assert.assertNull(result);

    Assert.assertTrue("Expected file does not exist.", testFile.exists());

    String resultText = FileUtils.readFileToString(testFile);
    Assert.assertEquals(resultText, testData);
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:30,代码来源:CamelFileTest.java


注:本文中的org.kie.api.runtime.process.ProcessInstance类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。