org.activiti.engine.history.HistoricVariableInstanceQuery Java Examples

The following examples show how to use org.activiti.engine.history.HistoricVariableInstanceQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery variableValueNotEquals(String variableName, Object variableValue) {
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    if (variableValue == null) {
        throw new ActivitiIllegalArgumentException("variableValue is null");
    }
    this.variableName = variableName;
    queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.NOT_EQUALS, true);
    return this;
}
 
Example #2
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery excludeTaskVariables() {
    if (taskId != null) {
        throw new ActivitiIllegalArgumentException("Cannot use taskId together with excludeTaskVariables");
    }
    if (taskIds != null) {
        throw new ActivitiIllegalArgumentException("Cannot use taskIds together with excludeTaskVariables");
    }
    excludeTaskRelated = true;
    return this;
}
 
Example #3
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery variableValueEquals(String variableName, Object variableValue) {
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    if (variableValue == null) {
        throw new ActivitiIllegalArgumentException("variableValue is null");
    }
    this.variableName = variableName;
    queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.EQUALS, true);
    return this;
}
 
Example #4
Source File: CallActivityTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testNotInheritVariablesSubprocess() throws Exception {
  BpmnModel mainBpmnModel = loadBPMNModel(NOT_INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
  BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);

  processEngine.getRepositoryService()
      .createDeployment()
      .name("childProcessDeployment")
      .addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
  
  processEngine.getRepositoryService()
      .createDeployment()
      .name("mainProcessDeployment")
      .addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();
  
  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("var1", "String test value");
  variables.put("var2", true);
  variables.put("var3", 12345);
  variables.put("var4", 67890);

  ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);

  HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
  activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
  activityInstanceQuery.activityId("childProcessCall");
  HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
  String calledInstanceId = activityInstance.getCalledProcessInstanceId();

  HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
  variableInstanceQuery.processInstanceId(calledInstanceId);
  List<HistoricVariableInstance> variableInstances = variableInstanceQuery.list();

  assertEquals(0, variableInstances.size());
}
 
Example #5
Source File: CallActivityTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testInheritVariablesSubprocess() throws Exception {
  BpmnModel mainBpmnModel = loadBPMNModel(INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
  BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);

  processEngine.getRepositoryService()
      .createDeployment()
      .name("mainProcessDeployment")
      .addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();

  processEngine.getRepositoryService()
      .createDeployment()
      .name("childProcessDeployment")
      .addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();

  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("var1", "String test value");
  variables.put("var2", true);
  variables.put("var3", 12345);
  variables.put("var4", 67890);

  ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);

  HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
  activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
  activityInstanceQuery.activityId("childProcessCall");
  HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
  String calledInstanceId = activityInstance.getCalledProcessInstanceId();

  HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
  List<HistoricVariableInstance> variableInstances = variableInstanceQuery.processInstanceId(calledInstanceId).list();

  assertEquals(4, variableInstances.size());
  for (HistoricVariableInstance variable : variableInstances) {
    assertEquals(variables.get(variable.getVariableName()), variable.getValue());
  }
}
 
Example #6
Source File: HistoricVariableInstanceBaseResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addVariables(HistoricVariableInstanceQuery variableInstanceQuery, List<QueryVariable> variables) {
  for (QueryVariable variable : variables) {
    if (variable.getVariableOperation() == null) {
      throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
    }
    if (variable.getValue() == null) {
      throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
    }

    boolean nameLess = variable.getName() == null;

    Object actualValue = restResponseFactory.getVariableValue(variable);

    // A value-only query is only possible using equals-operator
    if (nameLess) {
      throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is not supported");
    }

    switch (variable.getVariableOperation()) {

    case EQUALS:
      variableInstanceQuery.variableValueEquals(variable.getName(), actualValue);
      break;

    default:
      throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
    }
  }
}
 
Example #7
Source File: HistoricVariableInstanceBaseResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected DataResponse getQueryResponse(HistoricVariableInstanceQueryRequest queryRequest, Map<String, String> allRequestParams) {
  HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();

  // Populate query based on request
  if (queryRequest.getExcludeTaskVariables() != null) {
    if (queryRequest.getExcludeTaskVariables()) {
      query.excludeTaskVariables();
    }
  }

  if (queryRequest.getTaskId() != null) {
    query.taskId(queryRequest.getTaskId());
  }
  
  if(queryRequest.getExecutionId() != null) {
    query.executionId(queryRequest.getExecutionId());
  }

  if (queryRequest.getProcessInstanceId() != null) {
    query.processInstanceId(queryRequest.getProcessInstanceId());
  }

  if (queryRequest.getVariableName() != null) {
    query.variableName(queryRequest.getVariableName());
  }

  if (queryRequest.getVariableNameLike() != null) {
    query.variableNameLike(queryRequest.getVariableNameLike());

  }

  if (queryRequest.getVariables() != null) {
    addVariables(query, queryRequest.getVariables());
  }

  return new HistoricVariableInstancePaginateList(restResponseFactory).paginateList(allRequestParams, query, "variableName", allowedSortProperties);
}
 
Example #8
Source File: CallActivityTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testNotInheritVariablesSubprocess() throws Exception {
  BpmnModel mainBpmnModel = loadBPMNModel(NOT_INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
  BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);

  processEngine.getRepositoryService()
      .createDeployment()
      .name("childProcessDeployment")
      .addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
  
  processEngine.getRepositoryService()
      .createDeployment()
      .name("mainProcessDeployment")
      .addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();
  
  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("var1", "String test value");
  variables.put("var2", true);
  variables.put("var3", 12345);
  variables.put("var4", 67890);

  ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);

  HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
  activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
  activityInstanceQuery.activityId("childProcessCall");
  HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
  String calledInstanceId = activityInstance.getCalledProcessInstanceId();

  HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
  variableInstanceQuery.processInstanceId(calledInstanceId);
  List<HistoricVariableInstance> variableInstances = variableInstanceQuery.list();

  assertEquals(0, variableInstances.size());
}
 
Example #9
Source File: CallActivityTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testInheritVariablesSubprocess() throws Exception {
  BpmnModel mainBpmnModel = loadBPMNModel(INHERIT_VARIABLES_MAIN_PROCESS_RESOURCE);
  BpmnModel childBpmnModel = loadBPMNModel(INHERIT_VARIABLES_CHILD_PROCESS_RESOURCE);

  processEngine.getRepositoryService()
      .createDeployment()
      .name("mainProcessDeployment")
      .addBpmnModel("mainProcess.bpmn20.xml", mainBpmnModel).deploy();

  processEngine.getRepositoryService()
      .createDeployment()
      .name("childProcessDeployment")
      .addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();

  Map<String, Object> variables = new HashMap<String, Object>();
  variables.put("var1", "String test value");
  variables.put("var2", true);
  variables.put("var3", 12345);
  variables.put("var4", 67890);

  ProcessInstance mainProcessInstance = runtimeService.startProcessInstanceByKey("mainProcess", variables);

  HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery();
  activityInstanceQuery.processInstanceId(mainProcessInstance.getId());
  activityInstanceQuery.activityId("childProcessCall");
  HistoricActivityInstance activityInstance = activityInstanceQuery.singleResult();
  String calledInstanceId = activityInstance.getCalledProcessInstanceId();

  HistoricVariableInstanceQuery variableInstanceQuery = historyService.createHistoricVariableInstanceQuery();
  List<HistoricVariableInstance> variableInstances = variableInstanceQuery.processInstanceId(calledInstanceId).list();

  assertEquals(4, variableInstances.size());
  for (HistoricVariableInstance variable : variableInstances) {
    assertEquals(variables.get(variable.getVariableName()), variable.getValue());
  }
}
 
Example #10
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery variableValueLike(String variableName, String variableValue) {
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    if (variableValue == null) {
        throw new ActivitiIllegalArgumentException("variableValue is null");
    }
    this.variableName = variableName;
    queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.LIKE, true);
    return this;
}
 
Example #11
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricVariableInstanceQuery variableValueLikeIgnoreCase(String variableName, String variableValue) {
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }
  if (variableValue == null) {
    throw new ActivitiIllegalArgumentException("variableValue is null");
  }
  this.variableName = variableName;
  queryVariableValue = new QueryVariableValue(variableName, variableValue.toLowerCase(), QueryOperator.LIKE_IGNORE_CASE, true);
  return this;
}
 
Example #12
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricVariableInstanceQuery variableValueLike(String variableName, String variableValue) {
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }
  if (variableValue == null) {
    throw new ActivitiIllegalArgumentException("variableValue is null");
  }
  this.variableName = variableName;
  queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.LIKE, true);
  return this;
}
 
Example #13
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricVariableInstanceQuery variableValueNotEquals(String variableName, Object variableValue) {
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }
  if (variableValue == null) {
    throw new ActivitiIllegalArgumentException("variableValue is null");
  }
  this.variableName = variableName;
  queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.NOT_EQUALS, true);
  return this;
}
 
Example #14
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricVariableInstanceQuery variableValueEquals(String variableName, Object variableValue) {
  if (variableName == null) {
    throw new ActivitiIllegalArgumentException("variableName is null");
  }
  if (variableValue == null) {
    throw new ActivitiIllegalArgumentException("variableValue is null");
  }
  this.variableName = variableName;
  queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.EQUALS, true);
  return this;
}
 
Example #15
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery variableValueLikeIgnoreCase(String variableName, String variableValue) {
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    if (variableValue == null) {
        throw new ActivitiIllegalArgumentException("variableValue is null");
    }
    this.variableName = variableName;
    queryVariableValue = new QueryVariableValue(variableName, variableValue.toLowerCase(), QueryOperator.LIKE_IGNORE_CASE, true);
    return this;
}
 
Example #16
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricVariableInstanceQuery excludeTaskVariables() {
  if (taskId != null) {
    throw new ActivitiIllegalArgumentException("Cannot use taskId together with excludeTaskVariables");
  }
  if (taskIds != null) {
    throw new ActivitiIllegalArgumentException("Cannot use taskIds together with excludeTaskVariables");
  }
  excludeTaskRelated = true;
  return this;
}
 
Example #17
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public HistoricVariableInstanceQuery orderByVariableName() {
    orderBy(HistoricVariableInstanceQueryProperty.VARIABLE_NAME);
    return this;
}
 
Example #18
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public HistoricVariableInstanceQuery excludeVariableInitialization() {
    excludeVariableInitialization = true;
    return this;
}
 
Example #19
Source File: HistoricVariableInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public HistoricVariableInstanceQuery orderByProcessInstanceId() {
    orderBy(HistoricVariableInstanceQueryProperty.PROCESS_INSTANCE_ID);
    return this;
}
 
Example #20
Source File: HistoryServiceImpl.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public HistoricVariableInstanceQuery createHistoricVariableInstanceQuery() {
    return new HistoricVariableInstanceQueryImpl(commandExecutor);
}
 
Example #21
Source File: HistoryService.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
/** Creates a new programmatic query to search for {@link HistoricVariableInstance}s. */
HistoricVariableInstanceQuery createHistoricVariableInstanceQuery();
 
Example #22
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public HistoricVariableInstanceQuery orderByVariableName() {
  orderBy(HistoricVariableInstanceQueryProperty.VARIABLE_NAME);
  return this;
}
 
Example #23
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public HistoricVariableInstanceQuery orderByProcessInstanceId() {
  orderBy(HistoricVariableInstanceQueryProperty.PROCESS_INSTANCE_ID);
  return this;
}
 
Example #24
Source File: HistoricVariableInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public HistoricVariableInstanceQuery excludeVariableInitialization() {
  excludeVariableInitialization = true;
  return this;
}
 
Example #25
Source File: HistoryServiceImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public HistoricVariableInstanceQuery createHistoricVariableInstanceQuery() {
  return new HistoricVariableInstanceQueryImpl(commandExecutor);
}
 
Example #26
Source File: HistoryService.java    From activiti6-boot2 with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new programmatic query to search for {@link HistoricVariableInstance}s.
 */
HistoricVariableInstanceQuery createHistoricVariableInstanceQuery();