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

Custom placeholders implementation #10

Closed
AntonOellerer opened this issue Sep 17, 2020 · 9 comments · Fixed by #12
Closed

Custom placeholders implementation #10

AntonOellerer opened this issue Sep 17, 2020 · 9 comments · Fixed by #12

Comments

@AntonOellerer
Copy link
Contributor

The concept of placeholders can be used to integrate optional functionality into the jocument library.
This could, for example, be tables of contents, custom processing of external files (inserting the abstract of a report).
In this issue, the implementation details of a "custom placeholder" standard library are discussed, for custom placeholder suggestions see #9.

@AntonOellerer
Copy link
Contributor Author

The way I see it, a custom placeholder library adds a lot of complexity to jocument seperated from the actual generating work.
Maybe it would be best to implement some kind "plugin system" where each placeholder (or groups of placeholders) are outsourced to another library.
Another way would be to very carefully consider each custom placeholder proposal and to restrict the set of custom placeholders to a certain subset directly included into the library.

@AntonOellerer
Copy link
Contributor Author

Codecitizen:

Maybe it would be best to implement some kind "plugin system" where each placeholder (or groups of placeholders) are outsourced to another library.

We already have a plugin system, since you can easily implement custom placeholders, but we have to make PlaceholderResolver an abstract class and add some registration/resolving logic. Like a program or template global custom placeholder registry. Would do in a separate issue.

I like how hamcrest separates its dependencies into hamcrest-core for the assertion mechanism and hamcrest-library for their standard lib. We could do jocuments-core jocuments-docx-elements jocuments-xlsx-elements or by type jocuments-table-elements ....

@AntonOellerer
Copy link
Contributor Author

Seems like a reasonable approach to me aswell +1
I would actually use this issue for discussing the registration/resolving logic.

Re packaging: Maybe like some apache projects, where the exposed packages are actually just wrapping of functionality taken from some repositories, so a placeholder resolver could be in multiple repositories?

@AntonOellerer
Copy link
Contributor Author

Codecitizen:

I would actually use this issue for discussing the registration/resolving logic.

I guess we should see the registration of customer palceholder defintions at the resolver level. The resolver is the component responsible for deciding how to replace a placeholder. So it should detect if its custom and if there's a implementation for it.

I could imagine this either being passed to the template or resolver directly as registry object or with an additional aspect oriented approach, where you place annotations on the resolver functions / clases (e.g. @DocumentPlaceholder(name = "PICTUER-TABLE", mimeTypes = {DOCX,XLSX})).

Re packaging: Maybe like some apache projects, where the exposed packages are actually just wrapping of functionality taken from some repositories, so a placeholder resolver could be in multiple repositories?

You mean like use case oriented? Like in Apache Commons?

@AntonOellerer
Copy link
Contributor Author

I could imagine this either being passed to the template or resolver directly as registry object or with an additional aspect oriented approach, where you place annotations on the resolver functions / clases (e.g. @DocumentPlaceholder(name = "PICTUER-TABLE", mimeTypes = {DOCX,XLSX})).

I like the Aspect oriented approach, generally I think the placeholders should be registered at the resolver, not the template, since the control of the generation service should be in the hands of the developers and not the user.

You mean like use case oriented? Like in Apache Commons?

Yes

@AntonOellerer
Copy link
Contributor Author

Codecitizen:
Maybe draw up a concept and research for aspect-o approaches

@AntonOellerer
Copy link
Contributor Author

If possible, placeholders should also be parameterisable (like e.g {{image https://www.example.com/image.jpg}})

@AntonOellerer
Copy link
Contributor Author

First sketch for how this could work:

  • Packages have to be included into project
  • Developer has to register desired modules at resolver startup
  • (Optionally, modules could also be toggled via special placeholders at document head, e.g. {{images}})
  • Modules can define their own aspects for cross cutting concerns (e.g. generate table of content after document generation finished)
  • Modules register @ resolver registry with name, get cast on retrieval and parameters passed

TODO: Determine whether necessary/how to do context passing in aspects

@AntonOellerer
Copy link
Contributor Author

AntonOellerer commented Sep 17, 2020

An implementation of a postprocessing approach can be seen in #16 .

After consultation with @amp-dt, it was decided that the approach should be done via the CustomPlaceholder (See #12) interface, and to document & merge the postprocessing for future use.

This was referenced Sep 17, 2020
@AntonOellerer AntonOellerer linked a pull request Sep 17, 2020 that will close this issue
@alexpartsch alexpartsch moved this from To do to In progress in Release First Major Version of jocument Sep 23, 2020
@alexpartsch alexpartsch added this to the Get Jocument Cleaned up milestone Sep 23, 2020
@AntonOellerer AntonOellerer moved this from In progress to To review in Release First Major Version of jocument Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants