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

Conversation

Nandanrshenoy
Copy link
Contributor

@Nandanrshenoy Nandanrshenoy commented Sep 20, 2024

git-issue-2334-fetch-variable-enhancement-for-process-instances-api(Get/Post) : enhance the Get Process List API (Both Post and Get methods) to include Process related variables in its response

related to: #2334

…iable-enhancement-for-process-instances-api(Get/Post)

Updated the Get/Post Methods for Process Instace list to accommodate variables only when WithVariablesInReturn is set to true

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
…ancement-for-process-instances-api(Get/Post)

Updated the Get/Post Methods for Process Instance list to accommodate variables only when WithVariablesInReturn is set to true

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
…ble-enhancement-for-process-instances-api(Get/Post)

Updated the Get/Post Methods for Process Instance list to accommodate variables only when WithVariablesInReturn is set to true

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
…hancement-for-process-instances-api(Get/Post)

Updated the Get/Post Methods for Process Instance list to accommodate variables only when WithVariablesInReturn is set to true

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
…fetch-variable-enhancement-for-process-instances-api(Get/Post)

Updated the Get/Post Methods for Process Instance list to accommodate variables only when WithVariablesInReturn is set to true

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
…iable-process-instance-api-enhancement

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

Signed-off-by: Shenoy, Nandan <Nandan.Shenoy@fmr.com>
@venetrius
Copy link
Member

Hi @Nandanrshenoy,
Thanks for creating a pull request. I will review it and get back to you.

@Nandanrshenoy
Copy link
Contributor Author

Thanks @venetrius for your support !!!

@Nandanrshenoy
Copy link
Contributor Author

@venetrius ,
Requesting your support for reviewing my contribution, so that I can concentrate on fixing some other issue.

Thanks and Regards,
Nandan Shenoy

@Nandanrshenoy
Copy link
Contributor Author

@venetrius ,
Hope your doing Great !!
When ever you have some time, request your support to kindly validate my PR.Thanks for your time.

Regards,
Nandan Shenoy

@Nandanrshenoy
Copy link
Contributor Author

@venetrius and @yanavasileva ,
Can some one kindly help me with a review for this PR.

Thanks and Regards,
Nandan Shenoy

@venetrius
Copy link
Member

Hi @Nandanrshenoy,
I had some time to check some part of the code in the PR.
I will need to do some manual test to check no regression were introduced as well as see if the added test cases are sufficient.

@@ -84,8 +85,18 @@ public List<ProcessInstanceDto> queryProcessInstances(

List<ProcessInstanceDto> instanceResults = new ArrayList<>();
for (ProcessInstance instance : matchingInstances) {
ProcessInstanceDto resultInstance = ProcessInstanceDto.fromProcessInstance(instance);
instanceResults.add(resultInstance);
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 !!!

@github-actions github-actions bot added the group:stale DRI: Yana label Jan 14, 2025
@github-actions github-actions bot added group:stale DRI: Yana and removed group:stale DRI: Yana labels Jan 21, 2025
@venetrius
Copy link
Member

Hi @Nandanrshenoy
I was not able to get back to you this week, I will try to do it within the next 2 weeks.

@Nandanrshenoy
Copy link
Contributor Author

Thanks @venetrius for the update.Will await for your inputs.

Regards,
Nandan Shenoy

Copy link
Member

@venetrius venetrius left a comment

Choose a reason for hiding this comment

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

Please see my comments.

instanceResults.add(resultInstance);
if (null!= queryDto.isWithVariablesInReturn() && queryDto.isWithVariablesInReturn()){
RuntimeService runtimeService = engine.getRuntimeService();
VariableMap variableMap = (VariableMap) runtimeService.getVariables(instance.getProcessInstanceId());
Copy link
Member

Choose a reason for hiding this comment

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

Querying all the variable instances within a single query would improve the performance.
Can you give it a try?
I think you can get the VariableInstances similar to this:

    List<VariableInstance> variableInstances =
        runtimeService.createVariableInstanceQuery().activityInstanceIdIn(
            matchingInstances.stream().map(ProcessInstance::getId).toArray(String[]::new)
        ).list();

then you need to match the VariableInstances to the Instances

type = "boolean"
desc = "Indicates if the variables associated with the process instance should be returned.
Value may only be true, as false is the default behavior." />

Copy link
Member

Choose a reason for hiding this comment

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

Currently variable values only returned for primitives and objects but not files.

{
        "links": [],
        "id": "0e0a6c59-f062-11ef-a093-22171c80391b",
        "definitionId": "invoice:1:0de5a5f8-f062-11ef-a093-22171c80391b",
        "businessKey": null,
        "caseInstanceId": null,
        "ended": false,
        "suspended": false,
        "tenantId": null,
        "variables": {
            "amount": {
                "type": "Double",
                "value": 30.0,
                "valueInfo": {}
            },
            "approverGroups": {
                "type": "Object",
                "value": [
                    "accounting",
                    "sales"
                ],
                "valueInfo": {
                    "objectTypeName": "java.util.ArrayList",
                    "serializationDataFormat": "application/x-java-serialized-object"
                }
            },
            "invoiceNumber": {
                "type": "String",
                "value": "GPFE-23232323",
                "valueInfo": {}
            },
            "invoiceDocument": {
                "type": "File",
                "value": null,
                "valueInfo": {
                    "filename": "invoice.pdf",
                    "mimeType": "application/pdf"
                }
            },
            "creditor": {
                "type": "String",
                "value": "Great Pizza for Everyone Inc.",
                "valueInfo": {}
            },
            "invoiceCategory": {
                "type": "String",
                "value": "Travel Expenses",
                "valueInfo": {}
            }
        }
    },

This is not bug and inline with the user experience in other queries but it should be reflected in the docs as well

when(runtimeServiceMock.getVariables(anyString())).thenReturn(mockInstanceWithVariable);

given()
.queryParam("withVariablesInReturn", false)
Copy link
Member

Choose a reason for hiding this comment

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

The default behaviour is that withVariablesInReturn is not part of the request. If withVariablesInReturn is not present then it is the same sa withVariablesInReturn is false

when(sampleInstanceQuery.listPage(0, 1)).thenReturn(mockProcessInstanceList);

VariableMap mockInstanceWithVariable = MockProvider.createMockSerializedVariables();
when(runtimeServiceMock.getVariables(anyString())).thenReturn(mockInstanceWithVariable);
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to check if getVariables is called with the actual processInstanceId and not any strig.

@github-actions github-actions bot added the group:stale DRI: Yana label Feb 22, 2025
Copy link

github-actions bot commented Mar 4, 2025

Closing due to lack of requested feedback. If you would like us to look at this, please provide the requested information to re-open the PR.

@github-actions github-actions bot closed this Mar 4, 2025
@Nandanrshenoy
Copy link
Contributor Author

@venetrius ,Thanks for your feedback.Let me take some time and go through your review comments. Will circle back incase I need any inputs.

Regards,
Nandan Shenoy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants