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

CobiGen pipeline for reducing templates #676

Open
jdiazgon opened this issue Jun 26, 2018 · 5 comments
Open

CobiGen pipeline for reducing templates #676

jdiazgon opened this issue Jun 26, 2018 · 5 comments
Assignees

Comments

@jdiazgon
Copy link
Member

Currently, one of our major issues is that we have to maintain several plug-ins which make use of similar templates.

For example, the OpenAPI plug-in contains increments/templates like TOs or CRUD REST services which are very similar to the ones used in the Java plug-in.

We could only have templates for the Entity infrastructure and then, using the generated entities as input, generate with them the rest of increments.

Therefore, we must implement some kind of logic inside the CobiGen core to create like a generation pipeline for being able to generate in multiple steps.

@jdiazgon
Copy link
Member Author

jdiazgon commented Jun 27, 2018

As discussed with @maybeec we have devised some ideas that I would like to reflect:

  1. We will add a new configuration feature on the context.xml so that the user is able define a generation pipeline. For instance:
<gen-pipeline>
	<incrementRef ref="crud_openapi_java_server_app"/>
	<incrementRef ref="crud_java_server_app::inc21" use-input="${variables.entityName}Entity.java"/>
  </gen-pipline>

This configuration means that from an OpenAPI file we will generate the crud_openapi_java_server_app templates. Then, using the generated ${variables.entityName}Entity.java, we will generate templates from the crud_java_server_app using the increment with id "inc21".

  1. The second increment will completely wait until the first increment has been generated. Then we need some logic to try to compile the generated files from the first increment (maybe by a method tryCompile() to try to compile with each plug-in?). This way, we will be able to use the pojo.classobject and reflection. If compiling was not possible, we will have to use the java source file rather than the class object and generate with that data.

Although this issue is tricky, it will highly improve maintainability of the templates and reduce the development time for the next plug-ins templates.

@maybeec
Copy link
Member

maybeec commented Jun 27, 2018

it should be

<gen-pipeline>
	<incrementRef ref="crud_java_server_app"/>
	<incrementRef ref="crud_openapi_angular_client_app::inc21" use-input="${variables.entityName}Entity.java"/>
  </gen-pipline>

for a correct example, as the entity is generated by crud_java_server_app.

@jdiazgon
Copy link
Member Author

You are right, I misspelled it. I meant generating from an OpenAPI file the entity infrastructure, and then with crud_java_server_app generating for instance the REST services.

I have already edited my comment.

@jdiazgon
Copy link
Member Author

jdiazgon commented Sep 6, 2019

Description

With our new CobiGen refactoring, where we will facilitate the creation of new plugins for very different languages, we will have a lot of new templates coming.

Currently, is already hard to maintain our templates. For instance, we generate the same Angular client from different inputs:

  • From OpenAPI.
  • From a Java ETO.
  • From a Typeorm entity.
  • Also an implementation of ngrx from Java ETO.

And the same applies to Ionic:

  • From OpenAPI.
  • From Java ETO.

Unfortunately, our models are slightly different between plugins, but my proposal is the following:

  • Let's foster this task to be finished, so that we can reduce as much templates as possible.
  • Related to Angular and Ionic client generation, we actually only need the properties of the entity. I would propose to generate always a Java ETO from OpenAPI or Typeorm, and then generate Angular and Ionic using that ETO. What do you think?

@maybeec
Copy link
Member

maybeec commented Apr 22, 2020

After a short discussion in comparison to #1125 with @jdiazgon and @lilliCao , we identified the need to specify the pipeline node within the templates xml and structure it like this:

<pipeline>
    <incrementRef ref="dataaccess_infrastructure" use-input="${variables.entityName}Entity.java">
      <inrementRef ref="crud_java_server_app::inc32"/>
    </triggerRef>
  </pipeline>

@maybeec maybeec removed this from the cobigen-core-v5.1.0 milestone Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants