Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/git issue 2334 fetch variable process instance api enhancement #4641

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Prev Previous commit
Update ProcessInstanceRestServiceImpl.java git issue-2334 : fetch-var…
…iable-process-instance-api-enhancement

git issue-2334 : fetch-variable-process-instance-api-enhancement

Signed-off-by: Shenoy, Nandan <[email protected]>
  • Loading branch information
Nandanrshenoy authored Aug 30, 2024
commit 51b452c9eac2bcb737037395d12178ddf659938f
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,23 @@ public List<ProcessInstanceDto> getProcessInstances(

@Override
public List<ProcessInstanceDto> queryProcessInstances(
ProcessInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
RuntimeService runtimeService = engine.getRuntimeService();
ProcessInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
ProcessInstanceQuery query = queryDto.toQuery(engine);

List<ProcessInstance> matchingInstances = QueryUtil.list(query, firstResult, maxResults);

List<ProcessInstanceDto> instanceResults = new ArrayList<>();
for (ProcessInstance instance : matchingInstances) {
if (null!= queryDto.isWithVariablesInReturn() && queryDto.isWithVariablesInReturn()){
VariableMap variableMap = (VariableMap) runtimeService.getVariables(instance.getProcessInstanceId());
Map<String, VariableValueDto> variableValueDtoMap= VariableValueDto.fromMap(variableMap);
ProcessInstanceWithVariablesDto resultInstanceWithVariable = new ProcessInstanceWithVariablesDto(instance);
resultInstanceWithVariable.setVariables(variableValueDtoMap);
instanceResults.add(resultInstanceWithVariable);
}
if (null!= queryDto.isWithVariablesInReturn() && queryDto.isWithVariablesInReturn()){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please make sure your code changes are formatted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @venetrius,Would you wish to provide me all the comments at once so that I can push the changes in one commit.Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Nandanrshenoy, I will try to get to it this week.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @venetrius for all the support .Will mean a lot !!!

RuntimeService runtimeService = engine.getRuntimeService();
VariableMap variableMap = (VariableMap) runtimeService.getVariables(instance.getProcessInstanceId());
Map<String, VariableValueDto> variableValueDtoMap= VariableValueDto.fromMap(variableMap);
ProcessInstanceWithVariablesDto resultInstanceWithVariable = new ProcessInstanceWithVariablesDto(instance);
resultInstanceWithVariable.setVariables(variableValueDtoMap);
instanceResults.add(resultInstanceWithVariable);
}
else {
ProcessInstanceDto resultInstance = ProcessInstanceDto.fromProcessInstance(instance);
instanceResults.add(resultInstance);
Expand Down