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

[DataLayer] Data Layer Builder #1114

Closed
ky940819 opened this issue Jul 20, 2020 · 1 comment
Closed

[DataLayer] Data Layer Builder #1114

ky940819 opened this issue Jul 20, 2020 · 1 comment
Labels
enhancement New feature, or improvement to an existing feature.
Milestone

Comments

@ky940819
Copy link
Contributor

Feature Request

Is your feature request related to a problem? Please describe.

It is difficult for custom components (non core-components) to implement the data layer.
The data layer objects, and most of the methods that do some heavy lifting (example: generating an ID) are not exported and thus cannot be accessed outside of the project.

There are two issues:

  1. It is challenging to implement the data layer for components that are not part of core components
  2. it is challenging to extend/modify the data layer for custom component models that are overlays/wrappers for a core components model

The current implementation requires that a client who wishes to provide data layer for their own components must either re-implement the data layer interfaces and all associated logic; or, if their component has a super type that is a core component, then in their model they may adapt the request to the super type model and get the data layer, and then wrap that data layer to add/remove/modify anything they want while keeping in mind that the data layer object returned from the super model does not take into account any of the custom logic they may have overridden in their implementation.

Describe the solution you'd like
I propose that a DataLayerBuilder be made available to provide an easy API for people to deliver data layer integration from their custom components. For ease of use, the builder should use the Fluent Interface design such that IDE autocompletion can largely guide it's use.

An example of what this would look like:

ComponentData data = DataLayerBuilder.forComponent()
    .withId(() -> /* generate ID */)
    .withTitle(this::getTitle)
    .withDescription(this::getDescription)
    .withText(() -> "some text")
    .withLastModifiedDate(this::getLastModifiedDate)
    .withLinkUrl(this::getLinkUrl)
    .withType(resource::getResourceType)
    .build();

Are there alternatives?
Require that clients fully implement custom classes that match the *Data interfaces.

Documentation
Will provide JavaDocs in PR; however, I would appreciate input on technical documentation.

For further information please see discussion on the google group:
https://groups.google.com/g/aem-core-components-dev/c/kvhg-OQITIY

@vladbailescu vladbailescu added enhancement New feature, or improvement to an existing feature. pull request Has a pull request associated. labels Jul 24, 2020
@vladbailescu vladbailescu added this to the 2.12.0 milestone Jul 24, 2020
@ky940819
Copy link
Contributor Author

ky940819 commented Aug 1, 2020

Hello,

A quick question:
Is there interest in expanding this issue to include moving some of the internal logic for testing the produced DataLayer JSON models to the core.wcm.components.junit.core so as to allow developers who are integrating DataLayer into their personal projects an easy mechanism by which to test the JSON serialization against a local file?

I haven't fully assessed the work required, but at the very least i think from the core module test sources (com.adobe.cq.wcm.core.components.Utils) the following would need to be moved to the public test utilities:

  • Utils#enableDataLayer(AemContext, boolean) - So as to allow DL to be enabled for tests
  • Utils#enableDataLayerForOldAemContext(io.wcm.testing.mock.aem.junit.AemContext context, boolean) - could also be renamed to enableDataLayer since the signatures are different than the above example, even if they are named the same.
  • Utils#testDataLayer(ComponentData, String) - may possibly need some minor tweaks.

My thought here was just if we are going to make it easier for people to add DL to custom components, let's make it easy to test it as well.

@msagolj msagolj closed this as completed Oct 22, 2020
@msagolj msagolj removed the pull request Has a pull request associated. label Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, or improvement to an existing feature.
Projects
None yet
Development

No branches or pull requests

3 participants