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

Task api enhancement to include attachment and comments fields. #4306

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

sumankumarpani
Copy link

@sumankumarpani sumankumarpani commented Apr 29, 2024

Feat(engine) : User task api provide comment and attachment properties

  • Enhance the get tasks api to include "attachments" and "comments" boolean field which return existence of associated attachment and comments with the task.
  • Include boolean filter 'withCommentAttachmentInfo' and evaluate existence of attachment and comments when true.
  • Enhance Swagger specs

related to GIT Issue : #2404

image

@yanavasileva
Copy link
Member

Hi @sumankumarpani,

Thank you for raising this.
We will have a look and get back to you.

Best,
Yana

@sumankumarpani
Copy link
Author

Thanks @yanavasileva , let me know what are your thoughts/ suggestions.

Copy link
Member

@yanavasileva yanavasileva left a comment

Choose a reason for hiding this comment

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

@sumankumarpani, I haven't finish completely the review yet but I want to share early feedback and store my notes.
👍 Overall expression is that your approach is good, I just want to have a second look.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sumankumarpani
❌ brianwarner
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@yanavasileva yanavasileva left a comment

Choose a reason for hiding this comment

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

Thank you for considering my feedback so far, I managed to complete the review now.
Please see the comments below.

@@ -49,7 +50,9 @@ public class TaskDto {
private String formKey;
private CamundaFormRef camundaFormRef;
private String tenantId;

@JsonProperty("attachment")
Copy link
Member

Choose a reason for hiding this comment

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

❌ For consistency, let's remove the annotation:

Suggested change
@JsonProperty("attachment")

Copy link
Author

Choose a reason for hiding this comment

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

I was reluctant to add this, I am facing an weird issue where hasAttachment is translated to attachments instead of attachment in the json response, hence decided to add. Let me know your thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

I saw this. I will try to see from where it's coming.

Copy link
Member

Choose a reason for hiding this comment

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

You can also try to debug it.

Copy link
Author

Choose a reason for hiding this comment

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

I figured it , jackson considers the setter method to decide the boolean var name.

Comment on lines +1457 to +1458
this.attachmentExists = !getProcessEngine().getTaskService().getTaskAttachments(id).isEmpty();
this.commentExists = !getProcessEngine().getTaskService().getTaskComments(id).isEmpty();
Copy link
Member

Choose a reason for hiding this comment

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

❌ Please re-use the command context instead of executing command (get attachment/comments) in the command (task query):

Suggested change
this.attachmentExists = !getProcessEngine().getTaskService().getTaskAttachments(id).isEmpty();
this.commentExists = !getProcessEngine().getTaskService().getTaskComments(id).isEmpty();
this.attachmentExists = !Context.getCommandContext().getAttachmentManager().findAttachmentsByTaskId(id).isEmpty();
this.commentExists = !Context.getCommandContext().getCommentManager().findCommentsByTaskId(id).isEmpty();

Comment on lines +1108 to +1110
/**
* Evaluates existence of attachment and comments associated with the task, defaults to false.
*/
Copy link
Member

Choose a reason for hiding this comment

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

❌ Please add performance considerations to the javadoc. Adding the filter will do additional attachment and comments queries to the database, that might slow down the query in case of big size of the tables.

Comment on lines +5602 to +5603
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
Copy link
Member

Choose a reason for hiding this comment

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

❌ Add required history level (don't forget to add the imports):

Suggested change
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")

@@ -1441,6 +1449,13 @@ public List<Task> executeList(CommandContext commandContext, Page page) {
}
}

if (withCommentAttachmentInfo && Context.getProcessEngineConfiguration().getHistoryLevel()!= HistoryLevel.HISTORY_LEVEL_NONE) {
Copy link
Member

Choose a reason for hiding this comment

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

❌ Use equals to compare:

Suggested change
if (withCommentAttachmentInfo && Context.getProcessEngineConfiguration().getHistoryLevel()!= HistoryLevel.HISTORY_LEVEL_NONE) {
if (withCommentAttachmentInfo && !Context.getProcessEngineConfiguration().getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_NONE)) {

Comment on lines +35 to +36
import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
Copy link
Member

Choose a reason for hiding this comment

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

🔧 Following code styles guidelines:

Suggested change
import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Comment on lines +5617 to +5619
}
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
Copy link
Member

Choose a reason for hiding this comment

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

❌ Add required history level:

Suggested change
}
@Test
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")
}
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
@Deployment(resources = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml")

Copy link
Member

Choose a reason for hiding this comment

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

❌ I don't see an action on this comment (in OpenAPI, REST API, Java API):
#2404 (comment)
One option is the described here:
#2404 (comment)
Other option will be to add comment to the APIs that can be true only if withCommentAttachmentInfo filter is passed. That might create confusion in users.

Copy link
Author

Choose a reason for hiding this comment

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

@yanavasileva , I am exploring option 1 of extending the dto class and adding additional variables.

Copy link
Author

Choose a reason for hiding this comment

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

I got a doubt @yanavasileva , our changes should be applicable to GET & POST /task apis only ,and not /task/
{id} , let me know if my understanding is correct?

Copy link
Member

Choose a reason for hiding this comment

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

❌ In all OpenAPI files, hasAttachment/hasComment changes are not reflected.

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.

None yet

4 participants