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

AF-1987: Create a client side version of all appformer gwt startup services #724

Merged
merged 9 commits into from Jul 17, 2019

Conversation

jesuino
Copy link
Contributor

@jesuino jesuino commented Jul 3, 2019

This is the work for AF-1987. Dependencies that requires a server side dependency have a *-client-backend version:

  • uberfire-security-client-backend
  • uberfire-preferences-client-backend
  • uberfire-workbench-client-backend
  • uberfire-client-backend

Additional an annotation @WorkbenchClientEditor was created and a processor for this annotation generates the necessary activity.

Later work (jesuino' commits) include fixing tests, fixing webapps and adding new tests to cover the processor and a new panel.

During our tests we found that the dependency uberfire-preference-client-backend should be added to the webapps so it will work correctly. Otherwise the webapp fails during GWT compilation

These are the PRs that must be merged with this:

kiegroup/kie-wb-common#2738
kiegroup/kie-wb-distributions#944
kiegroup/jbpm-wb#1365
kiegroup/drools-wb#1181
kiegroup/optaplanner-wb#340

This PR is declaring some new dependencies versions introduced by this PR: kiegroup/droolsjbpm-build-bootstrap#985

@jesuino
Copy link
Contributor Author

jesuino commented Jul 3, 2019

cc @ederign @tiagobento would you please review this PR?

Thanks.

nativeRegisterGwtEditorProvider();
}

private native void nativeRegisterGwtEditorProvider() /*-{
Copy link
Contributor

@domhanak domhanak Jul 3, 2019

Choose a reason for hiding this comment

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

Do you mind moving the native code to a separate class? Having it here decreases the readability of the ActivityBeansCache

presenter.addPart(workbenchPartPresenter);
verify(placeManager).tryClosePlace(any(), any());
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Lines

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface GetContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add JavaDoc for this annotation?

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface SetContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add JavaDoc for this annotation?


/**
*
* This annotation works like {@code @WorkbenchEditor}, and can be used for editors client side only editors.
Copy link
Contributor

Choose a reason for hiding this comment

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

..used for editors client side only editors. -> ...used for client side only editors

public <U extends BasePreference<U>, T extends BasePreferencePortable<U>> void save(final T portablePreference,
final Command successCallback,
final ParameterizedCommand<Throwable> errorCallback) {

Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: maybe we could add comments on why save is not implemented here

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface IsClientEditor {

This comment was marked as outdated.

@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface IsTemplatePerspective {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we please add JavaDoc for these annotation?

* An Editor is an activity that is associated with a VFS path. It is expected that the editor will provide the end user
* some means of editing and saving the resource represented by the VFS path.
*/
public interface WorkbenchClientEditorActivity extends WorkbenchActivity {

This comment was marked as outdated.

@@ -69,4 +69,6 @@
* Disable support to close parts.
*/
void disableClosePart();

void disableExpandPart();

This comment was marked as outdated.


String identifier = null;

for (final AnnotationMirror am : classElement.getAnnotationMirrors()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

imho this for-cycle could be extracted to a private method (getIdentifier) for better readability

onStartup1ParameterMethodName = onStartupMethod.getSimpleName().toString();
}

final String onMayCloseMethodName = GeneratorUtils.getOnMayCloseMethodName(classElement,
Copy link
Contributor

@domhanak domhanak Jul 3, 2019

Choose a reason for hiding this comment

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

I think you could construct map of Map<String, ExecutableElement> and then the following parts of code could just process this map in cycle. The map could be created in separate method for better readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't understand exactly how this could be changed. I think the code for this was based on EditorActivityGenerator. I could make some changes if you want. One example is this if/else to determine if there's a startup method and if it has params, it looks like a boolean logic to me, where 1 is the method name and 0 null, so:

startup exists    startup has params    noParam   withParam
0                                          0                 0         0
1                                          0                 1         0  
0                                          1                 0         0                
1                                          1                 0         1

So the resulting code:

        final String onStartup0ParameterMethodName = (onStartupMethod != null && onStartupMethod.getParameters().isEmpty()) ? 
                                                               onStartupMethod.getSimpleName().toString() 
                                                               : null;
        final String onStartup1ParameterMethodName = (onStartupMethod != null && !onStartupMethod.getParameters().isEmpty()) ? 
                                                                    onStartupMethod.getSimpleName().toString() 
                                                                    : null;

which looks worse.

The whole method could be condensed in a map, and late a for in the map fill the methods accordingly, but I would vote to avoid change it because it is, as I said, based on EditorActivityGenerator. What do you think?

Copy link
Contributor

@domhanak domhanak Jul 12, 2019

Choose a reason for hiding this comment

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

I meant something like this

Map<String, String> methodNameMap = ... // or ExecutableElement and you could call setContentMethod.getSimpleName().toString(); on each value of the map later
// but I see that GeneratorUtils is not uniform and returns String in some cases and ExecutableElement in others
map.put("onCloseMethodName", onCloseMethodName);

/**
* A source code generator for Activities
*/
public class ClientEditorActivityGenerator extends AbstractGenerator {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am missing test for this

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 also missed the test for this, however, I noticed that it is tested by the processor itself. The processor calls the activity generator and when testing it we can check the activity generator results from there ( see WorkbenchClientEditorProcessorTest). I did not find specific tests for Activity Generators, but I break this in smaller methods (as you mentioned above) and unit test them. Please let me know what you think about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I was thinking more unit level, like testing that calling generate with some values returns expected StringBuffer

Copy link
Contributor

Choose a reason for hiding this comment

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

But I see your point, would it be possible to extend it to cover Lines 87 - 92? those two branches are not covered.

qualifiers));
}

//Validate getWidgetMethodName and isWidget
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: we could validate all 6 cases, collect errors and only throw exception afterwards. Instead of fixing one problem at a time, you could fix them all at once.

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 agree, but as I said above, it is looks to be based on the EditorActivityGenerator hence I was resistant to modify this class specifically

Copy link
Contributor

Choose a reason for hiding this comment

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

Imho, if we have an opportunity to improve, we should take it. Why copy old patterns when they can be improved?
After some closer code inspection I would leave this part as is and maybe improved the setup as i suggested here

Copy link
Contributor

@domhanak domhanak left a comment

Choose a reason for hiding this comment

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

Left some comments to start with, once the build passes I will continue with local testing

@jesuino
Copy link
Contributor Author

jesuino commented Jul 3, 2019

I see enforcer rules issues, I am checking it locally and will update the PR soon and then trigger a new build

@@ -66,4 +66,4 @@ errai.marshalling.serializableTypes=org.dashbuilder.dataprovider.StaticProviderT
org.dashbuilder.dataset.sort.ColumnSort \
org.dashbuilder.dataset.sort.DataSetSort \
org.dashbuilder.dataset.sort.SortedList

errai.ioc.enabled.alternatives=org.uberfire.preferences.client.store.PreferenceBeanStoreClientImpl
Copy link
Contributor

@tiagobento tiagobento Jul 3, 2019

Choose a reason for hiding this comment

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

Does this work? I can be mistaken, but I think uberfire-security-client-backend already has an alternative enabled for a PreferenceBeanStore.. don't they conflict during GWT compilation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I remove it I have the following error:

Unsatisfied constructor dependency @Default org.uberfire.preferences.shared.bean.PreferenceBeanStore for Class @Any @org.uberfire.ext.preferences.client.central.tree.TreeView() org.uberfire.ext.preferences.client.central.tree.TreeHierarchyStructurePresenter. Some beans were found that satisfied this dependency, but must be enabled:
[INFO] org.uberfire.preferences.client.store.PreferenceBeanStoreClientImpl

I did change from uberfire-preference-client-backend to uberfire-preference-client, perhaps I should keep uberfire-preference-client-backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed by also adding uberfire-preference-client dependency.

@jesuino
Copy link
Contributor Author

jesuino commented Jul 3, 2019

@domhanak Thanks for your comments, I addressed most of them in #373cbaa246c3f99ed80e62e0b297feca5a6c3472

I am not changing the ClientEditorActivityGenerator for the reasons I commented above, let me know your thoughts.

I need also to test more apps with the changes (part of AF-2018), but if you see any issue please let me know.

@jesuino
Copy link
Contributor Author

jesuino commented Jul 3, 2019

Jenkins execute full downstream build

@jesuino
Copy link
Contributor Author

jesuino commented Jul 4, 2019

Jenkins execute full downstream build

@tiagobento
Copy link
Contributor

Jenkins please retest this

@tiagobento
Copy link
Contributor

Jenkins execute full downstream build

@ederign
Copy link
Member

ederign commented Jul 5, 2019

Jenkins please retest this

@jesuino
Copy link
Contributor Author

jesuino commented Jul 5, 2019

thanks @tiagobento

@@ -296,6 +323,9 @@ private boolean activitySupportsPath(ActivityAndMetaInfo activity, Path path) {
return new ArrayList<String>(activitiesById.keySet());
}

public void noOp() {
Copy link
Contributor

Choose a reason for hiding this comment

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

A small comments inside of this method explaining it could help with readiability

Copy link
Contributor

Choose a reason for hiding this comment

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

// Does nothing, simulates...

@jesuino
Copy link
Contributor Author

jesuino commented Jul 11, 2019

Jenkins execute full downstream build

@jesuino
Copy link
Contributor Author

jesuino commented Jul 11, 2019

Jenkins execute full downstream build

@domhanak
Copy link
Contributor

jenkins retest this

@domhanak
Copy link
Contributor

@jesuino

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M1:enforce (no-duplicate-declared-dependencies) on project dashbuilder-services: Some Enforcer rules have failed

Looks like something is wrong. But I am not sure if it has something to do with the changes in the PR yet.

@ederign
Copy link
Member

ederign commented Jul 12, 2019

The dashbuilder failures should probably be a lack of rebase.

@ederign
Copy link
Member

ederign commented Jul 12, 2019

Jenkins execute full downstream build

@domhanak
Copy link
Contributor

jenkins execute full downstream build

@jesuino
Copy link
Contributor Author

jesuino commented Jul 15, 2019

I will trigger another build, but please notice that the failing tests seems unrelated

@jesuino
Copy link
Contributor Author

jesuino commented Jul 15, 2019

Jenkins execute full downstream build

@tiagobento
Copy link
Contributor

These tests failed, but they don't look related to me.

- org.jbpm.executor.impl.wih.AsyncContinuationSupportTest.testAsyncModeWithParallelGateway
- org.kie.server.integrationtests.drools.pmml.ApplyScorecardMultiModuleIntegrationTest.org.kie.server.integrationtests.drools.pmml.ApplyScorecardMultiModuleIntegrationTest
- org.jbpm.executor.cdi.CDISimpleExecutorTest.org.jbpm.executor.cdi.CDISimpleExecutorTest

@jesuino @ederign @domhanak If you agree, it looks good for me to merge.

@jesuino
Copy link
Contributor Author

jesuino commented Jul 16, 2019

@tiagobento I also think that these tests failures are unrelated to this PR, hence I would vote to merge it - also merge all the other related PRs,please

@jesuino
Copy link
Contributor Author

jesuino commented Jul 17, 2019

Jenkins execute full downstream build

@ederign
Copy link
Member

ederign commented Jul 17, 2019

Testing failures are not related: org.jbpm.executor.impl.wih.AsyncContinuationSupportTest.testAsyncModeWithParallelGateway
org.kie.server.integrationtests.drools.pmml.ApplyScorecardMultiModuleIntegrationTest.org.kie.server.integrationtests.drools.pmml.ApplyScorecardMultiModuleIntegrationTest
org.jbpm.executor.cdi.CDISimpleExecutorTest.org.jbpm.executor.cdi.CDISimpleExecutorTest

@ederign ederign merged commit b88c5b0 into kiegroup:master Jul 17, 2019
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