cancel
Showing results for 
Search instead for 
Did you mean: 

I want to update the value of bytes_ in act_ge_bytearray table. Please suggest as I am stuck and it is very urgent for me.

hassan9619
Champ in-the-making
Champ in-the-making

The task is completed and I have to update the value of bytearray in act_ge_bytearray table. Please suggest me

1 ACCEPTED ANSWER

daisuke-yoshimo
Star Collaborator
Star Collaborator

I'm sorry that the answer was delayed.
I made the sample code to modify binary variable after process completing.

ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().addInputStream("myProcess.bpmn20.xml", new FileInputStream(filename))
.deploy();

// Process executed

Map<String, Object> var1 = new HashMap<String, Object>();
var1.put("aaa", "bbb");
Map<String, Object> var = new HashMap<String, Object>();
var.put("var1", var1);
ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("myProcess", var);
Task task = processEngine.getTaskService().createTaskQuery().processInstanceId(pi.getId()).singleResult();
processEngine.getTaskService().complete(task.getId());

// Alteration of history

((ProcessEngineConfigurationImpl) processEngineConfiguration).getCommandExecutor().execute(new Command<Object>() {
  public Object execute(CommandContext commandContext) {
    HistoricVariableInstance historicVar = processEngine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).singleResult();
     HistoricVariableInstanceEntity entity = (HistoricVariableInstanceEntity) historicVar;
    var1.put("ccc", "ddd");
     final VariableTypes variableTypes = Context.getCommandContext().getProcessEngineConfiguration().getVariableTypes();
    final VariableType variableType = variableTypes.findVariableType(entity.getValue());
    entity.setVariableType(variableType);
    variableType.setValue(var1, entity);
    return null;
  }
});

View answer in original post

1 REPLY 1

daisuke-yoshimo
Star Collaborator
Star Collaborator

I'm sorry that the answer was delayed.
I made the sample code to modify binary variable after process completing.

ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();
repositoryService.createDeployment().addInputStream("myProcess.bpmn20.xml", new FileInputStream(filename))
.deploy();

// Process executed

Map<String, Object> var1 = new HashMap<String, Object>();
var1.put("aaa", "bbb");
Map<String, Object> var = new HashMap<String, Object>();
var.put("var1", var1);
ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("myProcess", var);
Task task = processEngine.getTaskService().createTaskQuery().processInstanceId(pi.getId()).singleResult();
processEngine.getTaskService().complete(task.getId());

// Alteration of history

((ProcessEngineConfigurationImpl) processEngineConfiguration).getCommandExecutor().execute(new Command<Object>() {
  public Object execute(CommandContext commandContext) {
    HistoricVariableInstance historicVar = processEngine.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).singleResult();
     HistoricVariableInstanceEntity entity = (HistoricVariableInstanceEntity) historicVar;
    var1.put("ccc", "ddd");
     final VariableTypes variableTypes = Context.getCommandContext().getProcessEngineConfiguration().getVariableTypes();
    final VariableType variableType = variableTypes.findVariableType(entity.getValue());
    entity.setVariableType(variableType);
    variableType.setValue(var1, entity);
    return null;
  }
});