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

JBPM-10058 Task form with LocalDateTime datatype displays time format… #2768

Merged
merged 1 commit into from
May 12, 2022

Conversation

bxf12315
Copy link
Member

@bxf12315 bxf12315 commented Apr 7, 2022

… even when the option is unflagged

Thank you for submitting this pull request

JIRA: (please edit the JIRA link if it exists)

[link](JBPM-10058)

referenced Pull Requests:

How to replicate CI configuration locally?

Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use build-chain tool to handle cross repository builds and be sure that we always use latest version of the code for each repository.

build-chain tool is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See local execution details to get more information about it.

How to retest this PR or trigger a specific build:
  • a pull request please add comment: Jenkins retest this

  • a full downstream build please add comment: Jenkins run fdb

  • a compile downstream build please add comment: Jenkins run cdb

  • a full production downstream build please add comment: Jenkins execute product fdb

  • an upstream build please add comment: Jenkins run upstream

Copy link

@jstastny-cz jstastny-cz left a comment

Choose a reason for hiding this comment

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

Just naming convention remarks.

@bxf12315
Copy link
Member Author

bxf12315 commented Apr 7, 2022

Jenkins retest this

1 similar comment
@bxf12315
Copy link
Member Author

bxf12315 commented Apr 7, 2022

Jenkins retest this

@bxf12315
Copy link
Member Author

bxf12315 commented Apr 8, 2022

Jenkins run fdb

@yesamer
Copy link
Member

yesamer commented Apr 11, 2022

jenkins retest this please

@nmirasch
Copy link
Contributor

@bxf12315 It works fine and changes looks good. I just miss some testing

@ChughShilpa
Copy link

@bxf12315
With Show Time Unselected:
When tried to submit the process form
(http://localhost:8080/kie-server/services/rest/server/containers/03145275/forms/processes/_03145275.TestDate/content)
got some server error (please see attached screenshot and logs)

logs.txt
Screenshot

@jstastny-cz
Copy link

@bxf12315 With Show Time Unselected: When tried to submit the process form (http://localhost:8080/kie-server/services/rest/server/containers/03145275/forms/processes/_03145275.TestDate/content) got some server error (please see attached screenshot and logs)

logs.txt Screenshot

@jstastny-cz jstastny-cz reopened this Apr 13, 2022
@jstastny-cz
Copy link

I am sorry, wrong button :-( .

I just wanted to confirm Shilpa's finding. I am able to reproduce the same using FDB build.

@jstastny-cz
Copy link

It seems we should extend testing as proposed by @nmirasch and test that the server is able to handle the localdatetime without time part.

@bxf12315
Copy link
Member Author

Updated, later I will add some tests for it. Thanks
@ChughShilpa @jstastny-cz

@bxf12315
Copy link
Member Author

@nmirasch @jstastny-cz UT added.

@bxf12315
Copy link
Member Author

Jenkins retest this

@bxf12315
Copy link
Member Author

Jenkins run fdb

@@ -503,6 +503,7 @@ private String getFieldType(FormField field) {
default:
switch (field.getType()) {
case "java.time.LocalDateTime":
return "datetime-local";

Choose a reason for hiding this comment

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

This does not change the result of the switch, is that a leftover?

Copy link
Member Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

There's no operational difference in previous:

                     case "java.time.LocalDateTime":
                     case "java.util.Date":
                     case "java.sql.Date":
                     case "java.sql.Timestamp":
                         return "datetime-local";

and after this change:

                     case "java.time.LocalDateTime":
                         return "datetime-local";
                     case "java.util.Date":
                     case "java.sql.Date":
                     case "java.sql.Timestamp":
                         return "datetime-local";

So IMO this should be fixed or reverted.

Copy link
Member Author

Choose a reason for hiding this comment

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

previous "java.time.LocalDateTime" return default name, now is "datetime-local"

Choose a reason for hiding this comment

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

In original switch the case statement "case "java.time.LocalDateTime": was activated when input matching the literal so the first return value was actually returned. That's the way of execution in case statement without break statement is to continue in the following lines (and also cross cases) until it reaches interruption point (usually a break statement in this case it's return). In any case those two switches are identical when it comes to how it's executed.
The default branch is activated only when none of the cases matched the input value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I'm with Jan here, if the case statement doesn't have a end (break/return) the execution will continue until it reaches the next return/break

Choose a reason for hiding this comment

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

@pefernan wdyt, should we rollback this change? IMO it's unnecessary isolated change of coding style - there is another approach applied for the rest of cases, so diverging might puzzle people (it did puzzle myself).

Copy link
Member

Choose a reason for hiding this comment

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

totally

processAssetDesc.setId("test-id");

BootstrapFormRenderer bootstrapFormRenderer = new BootstrapFormRenderer();
String outString = bootstrapFormRenderer.renderProcess("test-contianerId", processAssetDesc, form);

Choose a reason for hiding this comment

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

Suggested change
String outString = bootstrapFormRenderer.renderProcess("test-contianerId", processAssetDesc, form);
String outString = bootstrapFormRenderer.renderProcess("test-containerId", processAssetDesc, form);

@bxf12315
Copy link
Member Author

Jenkins run fdb

@bxf12315
Copy link
Member Author

Jenkins run fdb

@bxf12315
Copy link
Member Author

Jenkins run fdb

@bxf12315
Copy link
Member Author

jenkins retest this please

@bxf12315
Copy link
Member Author

bxf12315 commented May 7, 2022

Jenkins run fdb

@bxf12315
Copy link
Member Author

bxf12315 commented May 8, 2022

Jenkins run fdb

@bxf12315
Copy link
Member Author

bxf12315 commented May 8, 2022

Jenkins run fdb

@bxf12315
Copy link
Member Author

bxf12315 commented May 9, 2022

@ChughShilpa @jstastny-cz @nmirasch @pefernan updated, please check agian,

@ChughShilpa
Copy link

ChughShilpa commented May 9, 2022

@bxf12315
Tested with latest fdb and https://issues.redhat.com/secure/attachment/12692075/12692075_reproducer_03145275.zip (which includes only "ProcessLocalDateTime" )

  • With ShowTime Unchecked:

Start the process from kie-server

  • date is visible in both kie-server and BC
  • can modify and save through kie-server and change is correctly visible in kie-server and BC
  • can modify and save through BC but no change is visible either in kie-server or in BC

Start the process from BC

  • no value is visible in kie-server. Only 'mm/dd/yy' format is visible
  • no value is visible in BC. Only 'datebirth' label is visible
  • can modify and save through kie-server and change is correctly visible in kie-server and BC
  • can modify and save through BC but no change is visible either in kie-server or in BC

@bxf12315
Copy link
Member Author

bxf12315 commented May 9, 2022

@bxf12315 Tested with latest fdb and https://issues.redhat.com/secure/attachment/12692075/12692075_reproducer_03145275.zip (which includes only "ProcessLocalDateTime" )

  • With ShowTime Unchecked:

Start the process from kie-server

  • date is visible in both kie-server and BC
  • can modify and save through kie-server and change is correctly visible in kie-server and BC
  • can modify and save through BC but no change is visible either in kie-server or in BC

Start the process from BC

BC. can not save local-datetime, so the. issue related to kie-server, I think we needs create new issue for it.

  • no value is visible in kie-server. Only 'mm/dd/yy' format is visible
  • no value is visible in BC. Only 'datebirth' label is visible
  • can modify and save through kie-server and change is correctly visible in kie-server and BC
  • can modify and save through BC but no change is visible either in kie-server or in BC

@ChughShilpa
Copy link

Agree with you @bxf12315 , these issues are not particularly related to this change.

@@ -503,6 +503,7 @@ private String getFieldType(FormField field) {
default:
switch (field.getType()) {
case "java.time.LocalDateTime":
return "datetime-local";
Copy link
Member

Choose a reason for hiding this comment

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

I'm with Jan here, if the case statement doesn't have a end (break/return) the execution will continue until it reaches the next return/break

@@ -409,7 +409,10 @@ protected void processFormLayout(FormInstance topLevelForm,
if (outputs.get(field.getBinding()) != null) {
value = outputs.get(field.getBinding());
}


if (value != null && value.toString().length() >= 10 && "datetime-local".equals(fieldType) && !field.isShowTime()) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd do this inside of the next switch

@@ -503,6 +503,7 @@ private String getFieldType(FormField field) {
default:
switch (field.getType()) {
case "java.time.LocalDateTime":
return "datetime-local";
Copy link
Member

Choose a reason for hiding this comment

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

totally

@@ -762,6 +775,19 @@ protected String appendExtractionExpression(String type, String name, String id,
jsonTemplate.append("getMultipleInputData('")
.append(id)
.append("')");
} else if (type.equals("datetime-local")) {
if (isShowTime) {
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it make sense here to use a mechansim like the ones in the date type where the it converts the input value into the proper JS Date object correctly formatted with the getDateFormatted function instead of adding the value as string?

Copy link
Member Author

@bxf12315 bxf12315 May 10, 2022

Choose a reason for hiding this comment

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

getDateFormatted will return an object, we need string in here.

Map<String, Object> parameters = marshallerHelper.unmarshal(containerId, payload, marshallingType, Map.class);

@mareknovotny
Copy link
Member

jenkins retest this please

@nmirasch
Copy link
Contributor

@bxf12315 the fix worked fine with the reproducer attached to the jira. The only thing that failed was to store date without the show time check.

@bxf12315 bxf12315 force-pushed the JBPM-10058 branch 2 times, most recently from c504c4a to baf0116 Compare May 11, 2022 13:07
Copy link

@jstastny-cz jstastny-cz left a comment

Choose a reason for hiding this comment

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

LGTM. Tested fine.

Copy link
Contributor

@nmirasch nmirasch left a comment

Choose a reason for hiding this comment

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

this code solves the customer issue.

Copy link

@ChughShilpa ChughShilpa left a comment

Choose a reason for hiding this comment

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

Tested and it looks fine

@mareknovotny
Copy link
Member

jenkins retest this please

the build was green, the failure happened only on ant running jacoco coverage instrumentation

[2022-05-11T15:50:38.034Z] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.8:run (generate-aggregated-jacoco-report) on project droolsjbpm-integration: An Ant BuildException has occured: Unable to read execution data file /home/jenkins/workspace/KIE/main/pullrequest/droolsjbpm-integration-main.pr/bc/kiegroup_droolsjbpm_integration/target/jacoco.exec
[2022-05-11T15:50:38.034Z] [ERROR] around Ant part ...<report>... @ 7:11 in /home/jenkins/workspace/KIE/main/pullrequest/droolsjbpm-integration-main.pr/bc/kiegroup_droolsjbpm_integration/target/antrun/build-main.xml: EOFException
[2022-05-11T15:50:38.034Z] [ERROR] -> [Help 1]
[2022-05-11T15:50:38.034Z] [ERROR] 
[2022-05-11T15:50:38.034Z] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[2022-05-11T15:50:38.034Z] [ERROR] Re-run Maven using the -X switch to enable full debug logging.
[2022-05-11T15:50:38.034Z] [ERROR] 
[2022-05-11T15:50:38.034Z] [ERROR] For more information about the errors and possible solutions, please read the following articles:
[2022-05-11T15:50:38.034Z] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[2022-05-11T15:50:38.034Z] + test 1 -eq 0
[Pipeline] }

Copy link
Member

@pefernan pefernan left a comment

Choose a reason for hiding this comment

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

works! thanks @bxf12315

@sonarcloud
Copy link

sonarcloud bot commented May 12, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

91.1% 91.1% Coverage
0.9% 0.9% Duplication

@mareknovotny mareknovotny merged commit a5de604 into kiegroup:main May 12, 2022
bxf12315 added a commit to Cory-jbpm/droolsjbpm-integration that referenced this pull request Jun 14, 2022
bxf12315 added a commit to Cory-jbpm/droolsjbpm-integration that referenced this pull request Jul 22, 2022
nmirasch pushed a commit that referenced this pull request Jul 27, 2022
nmirasch pushed a commit that referenced this pull request Jul 27, 2022
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.

7 participants