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

Conversation

sumankumarpani
Copy link
Contributor

@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
Contributor 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

CLAassistant commented May 24, 2024

CLA assistant check
All committers have signed the CLA.

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.

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
Contributor 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
Contributor 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

@yanavasileva yanavasileva Jun 12, 2024

Choose a reason for hiding this comment

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

@sumankumarpani, the ticket was initially reported for GET /task REST API but covering GET /task/{id} will add consistency to the endpoints. The TaskDto is used as a return type for all of those endpoints so the made changes so far make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, Thanks.

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.

@github-actions github-actions bot added group:stale DRI: Yana and removed group:stale DRI: Yana labels Jun 15, 2024
Copy link

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.

@sumankumarpani
Copy link
Contributor Author

@yanavasileva Please help to reopen the pr, I have worked the changes but facing issues to sync it , requesting some time to sync my changes and update the pr.

@sumankumarpani
Copy link
Contributor Author

sumankumarpani commented Jun 25, 2024 via email

@yanavasileva yanavasileva reopened this Jun 26, 2024
@github-actions github-actions bot added group:stale DRI: Yana and removed group:closed-as-inactive DRI: Yana group:stale DRI: Yana labels Jun 27, 2024
Copy link

github-actions bot commented Jul 5, 2024

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.

Signed-off-by: Kumar Pani, Suman <Suman.KumarPani@fmr.com>
@brianwarner brianwarner force-pushed the feature/ENTDAPCOE-126-task-api-enhancements branch from 3ea772d to b03a241 Compare July 22, 2024 18:56
@sumankumarpani
Copy link
Contributor Author

@yanavasileva I have added some changes, please help to review them again.

@yanavasileva yanavasileva self-requested a review August 13, 2024 06:42
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.

Hi @sumankumarpani,

Thank you for your patience with this.
I am almost done with the review. I need to run some tests and clarify open points before we can merge the feature.
I have added my notes so they are documented for everyone to get access to them for reference. I will let you know in case any further input/action is needed from your side.

Best,
Yana

Comment on lines +149 to +150
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Copy link
Member

Choose a reason for hiding this comment

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

❌ Not needed as far as I can see.

Suggested change
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Produces(MediaType.APPLICATION_JSON)
public interface TaskRestService {

public static final String PATH = "/task";

@Path("/{id}")
TaskResource getTask(@PathParam("id") String id);
TaskResource getTask(@PathParam("id") String id, @QueryParam("withCommentAttachmentInfo") Optional<Boolean> withCommentAttachmentInfo);
Copy link
Member

Choose a reason for hiding this comment

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

Note to myself: check CI and if there are cons against using Optional.

Copy link
Member

@yanavasileva yanavasileva Aug 20, 2024

Choose a reason for hiding this comment

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

@sumankumarpani, the engine-rest changes are breaking the tests for one of our supported environments. I am checking how is best to adjust the new parameter and preserve backwards compatibility. I will contact you further with my findings.

If you want to see the failures for yourself, you can execute the following (with JDK 11):
mvn clean install -Pwildfly-compatibility -f engine-rest/engine-rest/pom.xml

Copy link
Contributor Author

@sumankumarpani sumankumarpani Aug 21, 2024

Choose a reason for hiding this comment

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

@yanavasileva I am seeing this error, are you seeing the same.
Response body doesn't match expectation.
Expected: is ""
Actual: {"type":"RuntimeException","message":"RESTEASY003875: Unable to find a constructor that takes a String param or a valueOf() or fromString() method for javax.ws.rs.QueryParam("withCommentAttachmentInfo") on public org.camunda.bpm.engine.rest.sub.task.TaskResource org.camunda.bpm.engine.rest.impl.TaskRestServiceImpl.getTask(java.lang.String,java.util.Optional) for basetype: java.util.Optional","code":null}

[ERROR] TaskVariableRestResourceInteractionTest.testGetObjectVariables:162 5 expectations failed.
Expected status code <200> but was <500>.

I couldn't find the exact reason yet, will update here if I get any clue. Meanwhile let me know if you recall handling similar in the past.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I observe similar errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yanavasileva I modified the the param Optional withCommentAttachmentInfo to Boolean withCommentAttachmentInfo and given it a default value false, to make it work. Let me know if we can proceed with the solution.

Copy link
Member

@yanavasileva yanavasileva Aug 28, 2024

Choose a reason for hiding this comment

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

Boolean withCommentAttachmentInfo and given it a default value false, to make it work.

It seems like a better fit. We use similar approach in other places too.
Please adjust the code, I will run then the tests again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yanavasileva I have pushed changes , please take a look.

Copy link
Member

@yanavasileva yanavasileva Aug 17, 2024

Choose a reason for hiding this comment

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

the response body can be TaskWithA..Dto, do we need to adjust the response dto in the OpenAPI?

@yanavasileva yanavasileva self-requested a review September 7, 2024 10:34
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 checked the changes. Overall it looks good, I need to perform some final testing.

Have a look at my suggestions.

Heads up, we approach the code freeze of the minor release.
❗ If you want the feature to be included in 7.22.0, please apply the feedback by 17th of September.

@@ -29,14 +29,15 @@
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
import java.util.List;
import java.util.Optional;
Copy link
Member

Choose a reason for hiding this comment

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

❌ Not needed anymore:

Suggested change
import java.util.Optional;

@@ -19,6 +19,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Copy link
Member

Choose a reason for hiding this comment

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

❌ Not needed:

Suggested change
import java.util.Optional;
import java.util.Optional;

Comment on lines 74 to 88
queryDto.setObjectMapper(getObjectMapper());

ProcessEngine engine = getProcessEngine();
TaskQuery query = queryDto.toQuery(engine);

List<Task> matchingTasks = executeTaskQuery(firstResult, maxResults, query);

List<TaskDto> result;
if (Boolean.TRUE.equals(queryDto.getWithCommentAttachmentInfo())) {
result = matchingTasks.stream().map(TaskWithAttachmentAndCommentDto::fromEntity).collect(Collectors.toList());
}
else {
result = matchingTasks.stream().map(TaskDto::fromEntity).collect(Collectors.toList());
}
return result;
Copy link
Member

Choose a reason for hiding this comment

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

❓ Do we need this change? Now the code is duplicated.

Suggested change
queryDto.setObjectMapper(getObjectMapper());
ProcessEngine engine = getProcessEngine();
TaskQuery query = queryDto.toQuery(engine);
List<Task> matchingTasks = executeTaskQuery(firstResult, maxResults, query);
List<TaskDto> result;
if (Boolean.TRUE.equals(queryDto.getWithCommentAttachmentInfo())) {
result = matchingTasks.stream().map(TaskWithAttachmentAndCommentDto::fromEntity).collect(Collectors.toList());
}
else {
result = matchingTasks.stream().map(TaskDto::fromEntity).collect(Collectors.toList());
}
return result;
return queryTasks(queryDto, firstResult, maxResults);

else {
result = matchingTasks.stream().map(TaskDto::fromEntity).collect(Collectors.toList());
}
return result;
}

public HalTaskList getHalTasks(UriInfo uriInfo, Integer firstResult, Integer maxResults) {
Copy link
Member

Choose a reason for hiding this comment

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

📓 No action, just comment. The param is not considered here. As Hal queries are used in Tasklist where we need performance.

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 @yanavasileva for your reviews. Certainly I am willing these changes to be part of 7.22 release. I am done with addressing the comments and unit/integrations tests are running fine. Please let me know if the platform/e2e tests ran well or need something to be addressed, I will push the changes accordingly at a single instance and we can wrap it up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yanavasileva I have addressed the pending comments.

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 the work on this! Changes now look good to me.
I will merge the PR later today and it will be part of 7.22.0 scheduled for next month.

@sumankumarpani
Copy link
Contributor Author

👍 Thank you for the work on this! Changes now look good to me. I will merge the PR later today and it will be part of 7.22.0 scheduled for next month.

Thanks for the update Yana :)

@yanavasileva yanavasileva merged commit ddf039c into camunda:master Sep 16, 2024
1 check passed
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.

3 participants