Пример #1
0
  @Override
  public Void execute(Context context) {

    CaseEventSupport caseEventSupport = getCaseEventSupport(context);
    caseEventSupport.fireBeforeCaseReopened(caseId, deploymentId, caseDefinitionId, data);
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);

    if (data != null && !data.isEmpty()) {
      logger.debug("Updating case file in working memory");
      Collection<? extends Object> caseFiles =
          ksession.getObjects(new ClassObjectFilter(CaseFileInstance.class));
      if (caseFiles.size() == 0) {
        throw new CaseNotFoundException("Case with id " + caseId + " was not found");
      }
      CaseFileInstance caseFile = (CaseFileInstance) caseFiles.iterator().next();
      FactHandle factHandle = ksession.getFactHandle(caseFile);

      caseFile.addAll(data);

      ksession.update(factHandle, caseFile);
    }
    logger.debug(
        "Starting process instance for case {} and case definition {}", caseId, caseDefinitionId);
    CorrelationKey correlationKey = correlationKeyFactory.newCorrelationKey(caseId);
    Map<String, Object> params = new HashMap<>();
    // set case id to allow it to use CaseContext when creating runtime engine
    params.put(EnvironmentName.CASE_ID, caseId);
    long processInstanceId =
        processService.startProcess(deploymentId, caseDefinitionId, correlationKey, params);
    logger.debug(
        "Case {} successfully reopened (process instance id {})", caseId, processInstanceId);
    caseEventSupport.fireAfterCaseReopened(
        caseId, deploymentId, caseDefinitionId, data, processInstanceId);
    return null;
  }
Пример #2
0
 /**
  * Starts a process with parameters.
  *
  * @param processId
  * @param parameters
  */
 public void startProcess(final String processId, final Map<String, Object> parameters) {
   if (deploymentService.getDeployedUnit(myUnitId) == null) {
     DeploymentUnit unit =
         new KModuleDeploymentUnit("com.jeetemplates.bpm", "jbpm6-mykjar", "1.0.0-SNAPSHOT");
     myUnitId = unit.getIdentifier();
     deploymentService.deploy(unit);
   }
   processService.startProcess(myUnitId, processId, parameters);
 }