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-8380] #1477

Merged
merged 3 commits into from May 14, 2019
Merged

[JBPM-8380] #1477

merged 3 commits into from May 14, 2019

Conversation

karlnicholas
Copy link
Contributor

Started with #1449 and did additional work to remove JBPMHelper.java and JBPMUnitTestCase.
Moved static routines from JBPMHelper to ProcessMain where they were exclusively used.
Moved a couple static fields from JBPMHelper to JbpmJunitBaseTestBase.java.

set proper default values in jBPM.properties
@ghost
Copy link

ghost commented Apr 8, 2019

Can one of the admins verify this PR? Comment with 'ok to test' to start the build.

@elguardian
Copy link
Member

@MarianMacik @mswiderski this is based on my previous commit.

@karlnicholas plz keep in mind that there are other places where this is used
https://github.com/kiegroup/droolsjbpm-tools/blob/401c43085cb1c00df11c1bf325a7e2c39a61d865/drools-eclipse/org.jbpm.eclipse/src/main/resources/org/jbpm/eclipse/wizard/project/ProcessMain-advanced.java.v5.template

Also claim the Jira when you are working on it. otherwise will cause a misscordination among contributors.

Thanks for the contribution !

@elguardian
Copy link
Member

this is ok to test

@karlnicholas
Copy link
Contributor Author

@MarianMacik @mswiderski this is based on my previous commit.
@karlnicholas plz keep in mind that there are other places where this is used
https://github.com/kiegroup/droolsjbpm-tools/blob/401c43085cb1c00df11c1bf325a7e2c39a61d865/drools-eclipse/org.jbpm.eclipse/src/main/resources/org/jbpm/eclipse/wizard/project/ProcessMain-advanced.java.v5.template
Also claim the Jira when you are working on it. otherwise will cause a misscordination among contributors.
Thanks for the contribution !

Hi,

Should a new Jira be opened for the droolsjbpm-tools? Should be easy to change?
I cannot change the Assignee field in JBPM Jira. Is there another way to claim the Jira?

@elguardian
Copy link
Member

@karlnicholas use the same naming convention as this one (same branch name)

@karlnicholas
Copy link
Contributor Author

karlnicholas commented Apr 11, 2019

@elguardian Okay, I looked at the droolsjbpm-tools and created PR kiegroup/droolsjbpm-tools#93.
One of the plugin code samples in the droolsjbpm-tools project is an exact match of https://github.com/kiegroup/jbpm/blob/master/jbpm-test/src/test/java/org/jbpm/test/ProcessMain.java and both of them require JBPMHelper to function properly. This is because JBPMHelper handles two JPA instantiations which these codes require. Previously I had just moved the code to the above ProcessMain but now I see it is required in two separate locations.

ProcessMain (and the plugin snippet) is not currently functioning properly without the changes to https://github.com/kiegroup/jbpm/blob/master/jbpm-test/src/test/filtered-resources/META-INF/persistence.xml made by this PR. This is because the schema for persistence unit "org.jbpm.services.task" has changed. I copied an updated version from somewhere else that works.

This means that the ProcessMain code was allowed to fall into disrepair since it is not tested during the build processes. I would recommend a new Jira be opened to convert ProcessMain to a properly functioning JUnit test case.

So, I did not completely remove JBPMHelper but I took away all dependencies from it except for the two places mentioned above and changed it to use PersistenceUtil for database requirements.

@elguardian
Copy link
Member

@MarianMacik ^^

@mswiderski
Copy link
Contributor

ok to test

@karlnicholas
Copy link
Contributor Author

karlnicholas commented Apr 17, 2019

Also please issue ok to test on Remove JBPMHelper #93 droolsjbpm-tools changes.

@mswiderski
Copy link
Contributor

@MarianMacik @elguardian guys, could you please review and approve so it can be merged?

@MarianMacik
Copy link
Member

@karlnicholas So if I understood correctly you didn't remove JBPMHelper because it manages 2 datasources? Is this what you mean by JPA installations? I can see that JBPMHelper is instantiating the jdbc/jbpm-ds datasource here:

https://github.com/kiegroup/jbpm/pull/1477/files#diff-2ac0d6e56076eabf2e312f84f53a4663R54

But I cannot see where it is instantiating the second one for task service which is later used in this method:

https://github.com/kiegroup/jbpm/pull/1477/files#diff-2ac0d6e56076eabf2e312f84f53a4663R62

I don't understand why we cannot simply get rid of this class and move the relevant code to the let's say AbstractMain class or just create a new ExamplesUtil method or whatever. And I am wondering how it works with that second datasource since it is not created anywhere :) Then Persistence.createEntityManagerFactory(properties.getProperty("taskservice.datasource.name", "org.jbpm.services.task"), map); should simply fail.

user=sa
password=
url=jdbc:h2:tcp://localhost/~/jbpm-db
datasourceName=jdbc/jbpm-ds
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 leave only these properties here, others should not be used by PersistenceUtil class. They are only used by current jBPMHelper class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two, task service are used by ProcessMain which uses JBPMHelper. See additional comments below.

taskservice.enabled=true
taskservice.datasource.name=org.jbpm.services.task

Copy link
Member

Choose a reason for hiding this comment

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

So now we definitely don't need these properties.

@karlnicholas
Copy link
Contributor Author

karlnicholas commented Apr 18, 2019

@MarianMacik @elguardian -- Horribly long but sufficient explanation follows:

ProcessMain is the issue. It's in src/test/java/org/jbpm/test. This code is an exact copy of the code in the EclipsePlugin in the droolsjbpm-tools (somewhere, see other PR 93 above). This is the "two" places that JBPMHelper is used. This project and the other droolsjbpm-tools project.

In the droolsjbpm-tools project the code seems to be part of a template for an eclipse plugin. So, I assume after looking at it briefly that a user in eclipse can ask for the template and the class will be injected a project somewhere. Sort of a quickstart.

I don't know why the class (ProcessMain and also ProcessKModuleMain) are here in this project as well. I assume so that it can be run and tested. However the two classes are not tested as part of the build. They are both included as template code in the droolsjbpm-tools project but only ProcessMain is complicated enough to use JBPMHelper. ProcessKModuleMain is simple enough to just use PersistenceUtil only.

So, if you remove JBPMHelper the eclipse plugin will have template code that fails.

Having template code that fails is probably no big deal since it's not working at the moment anyway. This PR will fix it so that ProcessMain here in jbpm project will work, but at the cost of leaving JBPMHelper in the project. Even with the PR I'm not sure that the eclipse plugin template version of ProcessMain will work or even ever worked. The reason is that the code depends on being run from the test directory. See next paragraph.

Regards the second datasource mentioned. The persistence.xml file used by JBPMHelper contains several datasources. Once JPA reads it all the datasources are available to the running application. ProcessMain demonstrates using a TaskService so it not only connects to org.jbpm.persistence.jpa but also org.jbpm.services.task. The persistence.xml used is in src/test/filtered-resources/META-INF, not /src/main/resources/META-INF.

If you remove the taskservice.enabled=true property from the properties file then ProcessMain doesn't run the TaskService portion of the code. It doesn't fail, it just doesn't run it. Most (or all) of the code that handles the TaskService work for ProcessMain is in JBPMHelper. So ProcessMain looks very minimal but actually most of what it is doing is in JBPMHelper.

The Problem with moving all the code to ProcessMain is that it requires the datasource.properties file and the persistence.xml file to function properly and that is too complicated for an Eclipse plugin. I guess the Eclipse plugin just injects a single thing. To get around this whoever did the eclipse plugin put most of the functionality in JBPMHelper and made jbpm-test.jar a dependency.

Personally I would just remove ProcessMain from the project and the eclipse plugin and then you could also remove JBPMHelper but that is not my call. I seriously doubt, even with this PR, that the eclipse plugin template code that is ProcessMain functions well if you actually add it to a project. This is because the template ProcessMain code included in a project won't be running under test and so probably won't find the correct persistence.xml anyway.

@MarianMacik
Copy link
Member

OK, I see that it those two are persistence units reusing one datasource. So the property taskservice.datasource.name is quite misleading.

Never mind, regarding the jbpm-examples/src/main/resources/datasource.properties file, I still don't see how it is used by JBPMHelper since JBPMHelper getProperties() method only reads JBPM.properties file and not datasource.properties one. So I still think those other properties can be omitted since they are taken from JBPM.properties file.

Regarding deletion of JBPMHelper. I understand that JBPMHelper is used in Eclipse plugin etc. But if you replace JBPMHelper with a new ExamplesUtil as I mentioned and you just leave there what is actually used, I think we would be safe. The issue with leaving JBPMHelper is that it has been marked as deprecated so I think we have to come up with a new class and only leave there functionality which we really need.

I now realized that JBPMHelper says:

Since version 6.0 this class is deprecated. Instead <code>RuntimeManager</code> should be used directly.
See documentation on how to use <code>RuntimeManager</code>

So I think we need to just rewrite ProcessMain as ProcessKModuleMain to use runtime manager and engine and obtain ksession from there. Then we can get rid of the loadStatefulKnowledgeSession method etc.
So we have 2 possibilities I think - replace JBPMHelper with let's say ExamplesUtil and retain there only functionality which is needed - which means migrate to RuntimeManager way of setup, or delete JBPMHelper and move desired code to the ProcessMain/ProcessKModuleMain classes - but both of them will use runtime manager. Can you try that?

@karlnicholas
Copy link
Contributor Author

Okay, it wasn't so bad after looking a little closer to put the code completely in the ProcessMain and ProcessKModuleMain in jbpm-test and the plugin template as well. I just did away with reading any kind of configuration file and hardcoded driver parameters for H2. I think it is fine since it is just example code anyway. Really, it seems much cleaner anyway since you can easily see what's going on.

Copy link
Member

@MarianMacik MarianMacik left a comment

Choose a reason for hiding this comment

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

Looks very good now. Just minor suggestions and we are good to merge.

user=sa
password=
url=jdbc:h2:tcp://localhost/~/jbpm-db
datasourceName=jdbc/jbpm-ds
Copy link
Member

Choose a reason for hiding this comment

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

So now we definitely don't need these properties.

@MarianMacik
Copy link
Member

looks good now, will try to run full downstream build just to check if nothing is broken

jenkins execute full downstream build

@MarianMacik
Copy link
Member

jenkins execute full downstream build

@karlnicholas
Copy link
Contributor Author

karlnicholas commented May 2, 2019

Also don't forget PR kiegroup/droolsjbpm-tools#93.

@karlnicholas karlnicholas reopened this May 2, 2019
@MarianMacik
Copy link
Member

Yes, I know about that one too. For that we don't have downstream build, just the repo build.
Here, in FDB there were Just 2 unrelated tests, will trigger it once more and if it is OK, we can merge.

jenkins execute full downstream build

@MarianMacik
Copy link
Member

OK, I think we are good to go here. @elguardian can you approve?

@karlnicholas
Copy link
Contributor Author

Are this build errors a problem with this PR?

@mareknovotny
Copy link
Member

2 from 3 failed tests were seen before so they are not related, but I am not sure about org.kie.wb.selenium.ui.ProjectLibraryIntegrationTest.importAndBuildProjectFromStockRepository

@karlnicholas
Copy link
Contributor Author

2 from 3 failed tests were seen before so they are not related, but I am not sure about org.kie.wb.selenium.ui.ProjectLibraryIntegrationTest.importAndBuildProjectFromStockRepository

I looked: This is something from the Workbench and seems to be importing/testing a project named OptaCloud which seems to be about OptaPlanner. Shouldn't have anything to do with these changes.

@MarianMacik
Copy link
Member

I am 100% sure issues are not related. Can you rebase so we will merge this?

@karlnicholas
Copy link
Contributor Author

@MarianMacik Okay, I merged the latest changes from the master branch. Since there were conflicts I needed to create a new commit to support the merge changes. Should be good to go.

@MarianMacik
Copy link
Member

jenkins retest this

@MarianMacik
Copy link
Member

jenkins execute full downstream build

@MarianMacik
Copy link
Member

jenkins retest this

@MarianMacik
Copy link
Member

jenkins execute full downstream build

@MarianMacik
Copy link
Member

MarianMacik commented May 13, 2019

Looks good after full downstream. @mswiderski any comments?
Please check also kiegroup/droolsjbpm-tools#93

Copy link
Contributor

@mswiderski mswiderski left a comment

Choose a reason for hiding this comment

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

looks good to me

@MarianMacik MarianMacik merged commit ae8e83a into kiegroup:master May 14, 2019
@karlnicholas karlnicholas deleted the JBPM-8380 branch May 14, 2019 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants