From 4e5f836c6d6106082537f6d7582f857d353c01d0 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:01:35 +0530 Subject: [PATCH 1/7] new tutorial --- CustomerEntity.java | 60 +++++++++++++++++++++++++++++++++ index.asciidoc | 82 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 CustomerEntity.java create mode 100644 index.asciidoc diff --git a/CustomerEntity.java b/CustomerEntity.java new file mode 100644 index 00000000..b963a533 --- /dev/null +++ b/CustomerEntity.java @@ -0,0 +1,60 @@ +package com.example.application.cobigenjavaexample.customermanagement.dataaccess.api; + +import java.sql.Timestamp; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "Customer") +public class CustomerEntity { + + private String firstname; + + private String lastname; + + private int age; + + /** + * @return the firstname + */ + public String getFirstname() { + return firstname; + } + + /** + * @param firstname the firstname to set + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * @return the lastname + */ + public String getLastname() { + return lastname; + } + + /** + * @param lastname the lastname to set + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * @return the age + */ + public int getAge() { + return age; + } + + /** + * @param age the age to set + */ + public void setAge(int age) { + this.age = age; + } + +} \ No newline at end of file diff --git a/index.asciidoc b/index.asciidoc new file mode 100644 index 00000000..fb370dfc --- /dev/null +++ b/index.asciidoc @@ -0,0 +1,82 @@ += Generate Angular Client with devonfw +== Angular client generation with CobiGen +==== +With the CobiGen code generator you can easily generate components for your Angular application. +The following tutorial provides an example for using the CobiGen cli. +You can find more information on https://github.com/devonfw/cobigen/wiki/howto_angular-client-generation +## Prerequisites +* devonfw Ide + +## Learning goals. +Here in this tutorial we will learn the following: +* Create java project +* CobiGen to generate the Angular source code out of the java files + +==== + +[step] +-- +restoreDevonfwIde(["java", "mvn", "vscode"]) +-- + +For this tutorial an installation of the devonfw IDE is required first time you use it. The next step is to install the CobiGen CLI. +[step] +-- +installCobiGen() +-- + +CobiGen is build as an extensible framework for incremental code generation. It provides extension points for new input readers which allow reading new input types and converting them to an internally processed model.CobiGen uses the backend classes for generating your code used in the Angular application. So in the next steps you will create a java project, create a simple java class. +[step] +-- +createDevon4jProject("cobigenjavaexample") +-- + +This step is for building the java project. +[step] +== Build the java project +-- +buildJava("cobigenjavaexample") +-- + +==== +CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate code from one single java class based on existing templates. +[step] +-- + +createFile("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java") +adaptTemplatesCobiGen() +cobiGenJava("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java",[5]) +-- +The CobiGen code generator will generate code for Transfer object, REST service handling and data access and so on. + +For example, the following files are generated by CobiGen when using the specified templates: + +(5) TO's: Generates the related Transfer Objects. +- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java`{{open}} +- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerSearchCriteriaTo.java`{{open}} + +==== +==== +Now you can go through api module of your java project and use Cobigen again to generate your front end (angular code). +[step] +== Running CobiGen to generate to your Angular code +-- +cobiGenJava("cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java",[1]) +-- +The angular code generation is done now and the generated code is stored in the workspace/main/devon4ng-applicaiton-template directory. Make sure the backend server url is configured in environments/environment.ts file. + +==== + +The below commands are used, to run the angular front end. +npm install +ng serve + +[step] +-- +runClientNg("devon4ng-application-template", { "startupTime": 200, "port": 4200, "path": "" }) +-- +==== +Conclusion: In this Tutorial we learned the following things. +* How to create a java project. +* How to generate the Angular source code using CobiGen. +==== \ No newline at end of file From a563b1f3a9aaf60773f946e66f422dbbc655b075 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:09:43 +0530 Subject: [PATCH 2/7] new file --- angular-client-generation/index.asciidoc | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 angular-client-generation/index.asciidoc diff --git a/angular-client-generation/index.asciidoc b/angular-client-generation/index.asciidoc new file mode 100644 index 00000000..69f5606a --- /dev/null +++ b/angular-client-generation/index.asciidoc @@ -0,0 +1,82 @@ += Generate Angular Client with devonfw +== Angular client generation with CobiGen +==== +With the CobiGen code generator you can easily generate components for your Angular application. +The following tutorial provides an example for using the CobiGen cli. +You can find more information on https://github.com/devonfw/cobigen/wiki/howto_angular-client-generation +## Prerequisites +* devonfw Ide + +## Learning goals. +Here in this tutorial we will learn the following: +* Create java project +* CobiGen to generate the Angular source code out of the java files + +==== + +[step] +-- +restoreDevonfwIde(["java", "mvn", "vscode"]) +-- + +For this tutorial an installation of the devonfw IDE is required first time you use it. The next step is to install the CobiGen CLI. +[step] +-- +installCobiGen() +-- + +CobiGen is build as an extensible framework for incremental code generation. It provides extension points for new input readers which allow reading new input types and converting them to an internally processed model.CobiGen uses the backend classes for generating your code used in the Angular application. So in the next steps you will create a java project, create a simple java class. +[step] +-- +createDevon4jProject("cobigenjavaexample") +-- + +This step is for building the java project. +[step] +== Build the java project +-- +buildJava("cobigenjavaexample") +-- + +==== +CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate code from one single java class based on existing templates. +[step] +-- + +createFile("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java") +adaptTemplatesCobiGen() +cobiGenJava("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java",[5]) +-- +The CobiGen code generator will generate code for Transfer object, REST service handling and data access and so on. + +For example, the following files are generated by CobiGen when using the specified templates: + +(5) TO's: Generates the related Transfer Objects. +- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java`{{open}} +- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerSearchCriteriaTo.java`{{open}} + +==== +==== +Now you can go through api module of your java project and use Cobigen again to generate your front end (angular code). +[step] +== Running CobiGen to generate to your Angular code +-- +cobiGenJava("cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java",[1]) +-- +The angular code generation is done now and the generated code is stored in the workspace/main/devon4ng-applicaiton-template directory. Make sure the backend server url is configured in environments/environment.ts file. + +==== + +The below commands are used, to run the angular front end. +npm install +ng serve + +[step] +-- +runClientNg("devon4ng-application-template", { "startupTime": 200, "port": 4200, "path": "" }) +-- +==== +Conclusion: In this Tutorial we learned the following things. +* How to create a java project. +* How to generate the Angular source code using CobiGen. +==== From e2d8c51353478161ace5c27f610a268e4c39bf92 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:10:33 +0530 Subject: [PATCH 3/7] new file --- .../files/CustomerEntity.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 angular-client-generation/files/CustomerEntity.java diff --git a/angular-client-generation/files/CustomerEntity.java b/angular-client-generation/files/CustomerEntity.java new file mode 100644 index 00000000..6adb1d0e --- /dev/null +++ b/angular-client-generation/files/CustomerEntity.java @@ -0,0 +1,60 @@ +package com.example.application.cobigenjavaexample.customermanagement.dataaccess.api; + +import java.sql.Timestamp; + +import javax.persistence.Entity; +import javax.persistence.Table; + +@Entity +@Table(name = "Customer") +public class CustomerEntity { + + private String firstname; + + private String lastname; + + private int age; + + /** + * @return the firstname + */ + public String getFirstname() { + return firstname; + } + + /** + * @param firstname the firstname to set + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + /** + * @return the lastname + */ + public String getLastname() { + return lastname; + } + + /** + * @param lastname the lastname to set + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + /** + * @return the age + */ + public int getAge() { + return age; + } + + /** + * @param age the age to set + */ + public void setAge(int age) { + this.age = age; + } + +} From c9ecffd38736bf6957750bc125c87821b33bca81 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:11:22 +0530 Subject: [PATCH 4/7] delete file, not required --- CustomerEntity.java | 60 --------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 CustomerEntity.java diff --git a/CustomerEntity.java b/CustomerEntity.java deleted file mode 100644 index b963a533..00000000 --- a/CustomerEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.example.application.cobigenjavaexample.customermanagement.dataaccess.api; - -import java.sql.Timestamp; - -import javax.persistence.Entity; -import javax.persistence.Table; - -@Entity -@Table(name = "Customer") -public class CustomerEntity { - - private String firstname; - - private String lastname; - - private int age; - - /** - * @return the firstname - */ - public String getFirstname() { - return firstname; - } - - /** - * @param firstname the firstname to set - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - /** - * @return the lastname - */ - public String getLastname() { - return lastname; - } - - /** - * @param lastname the lastname to set - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - /** - * @return the age - */ - public int getAge() { - return age; - } - - /** - * @param age the age to set - */ - public void setAge(int age) { - this.age = age; - } - -} \ No newline at end of file From d95fe7db2544db08144809607379812d3f463765 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Tue, 9 Nov 2021 14:12:26 +0530 Subject: [PATCH 5/7] delete file as this is not required --- index.asciidoc | 82 -------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 index.asciidoc diff --git a/index.asciidoc b/index.asciidoc deleted file mode 100644 index fb370dfc..00000000 --- a/index.asciidoc +++ /dev/null @@ -1,82 +0,0 @@ -= Generate Angular Client with devonfw -== Angular client generation with CobiGen -==== -With the CobiGen code generator you can easily generate components for your Angular application. -The following tutorial provides an example for using the CobiGen cli. -You can find more information on https://github.com/devonfw/cobigen/wiki/howto_angular-client-generation -## Prerequisites -* devonfw Ide - -## Learning goals. -Here in this tutorial we will learn the following: -* Create java project -* CobiGen to generate the Angular source code out of the java files - -==== - -[step] --- -restoreDevonfwIde(["java", "mvn", "vscode"]) --- - -For this tutorial an installation of the devonfw IDE is required first time you use it. The next step is to install the CobiGen CLI. -[step] --- -installCobiGen() --- - -CobiGen is build as an extensible framework for incremental code generation. It provides extension points for new input readers which allow reading new input types and converting them to an internally processed model.CobiGen uses the backend classes for generating your code used in the Angular application. So in the next steps you will create a java project, create a simple java class. -[step] --- -createDevon4jProject("cobigenjavaexample") --- - -This step is for building the java project. -[step] -== Build the java project --- -buildJava("cobigenjavaexample") --- - -==== -CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate code from one single java class based on existing templates. -[step] --- - -createFile("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java") -adaptTemplatesCobiGen() -cobiGenJava("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java",[5]) --- -The CobiGen code generator will generate code for Transfer object, REST service handling and data access and so on. - -For example, the following files are generated by CobiGen when using the specified templates: - -(5) TO's: Generates the related Transfer Objects. -- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java`{{open}} -- `devonfw/workspaces/main/cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerSearchCriteriaTo.java`{{open}} - -==== -==== -Now you can go through api module of your java project and use Cobigen again to generate your front end (angular code). -[step] -== Running CobiGen to generate to your Angular code --- -cobiGenJava("cobigenjavaexample/api/src/main/java/com/example/application/cobigenjavaexample/customermanagement/logic/api/to/CustomerEto.java",[1]) --- -The angular code generation is done now and the generated code is stored in the workspace/main/devon4ng-applicaiton-template directory. Make sure the backend server url is configured in environments/environment.ts file. - -==== - -The below commands are used, to run the angular front end. -npm install -ng serve - -[step] --- -runClientNg("devon4ng-application-template", { "startupTime": 200, "port": 4200, "path": "" }) --- -==== -Conclusion: In this Tutorial we learned the following things. -* How to create a java project. -* How to generate the Angular source code using CobiGen. -==== \ No newline at end of file From 4a6bba8a244ab74554cd506c467d12f536f57158 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Thu, 11 Nov 2021 10:55:04 +0530 Subject: [PATCH 6/7] modified functions --- angular-client-generation/index.asciidoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/angular-client-generation/index.asciidoc b/angular-client-generation/index.asciidoc index 69f5606a..7153af97 100644 --- a/angular-client-generation/index.asciidoc +++ b/angular-client-generation/index.asciidoc @@ -44,8 +44,7 @@ CobiGen is integrated via plugin in the VS Code IDE. We will use it to generate -- createFile("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java") -adaptTemplatesCobiGen() -cobiGenJava("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java",[5]) +cobiGenJava("cobigenjavaexample/core/src/main/java/com/example/application/cobigenjavaexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8]) -- The CobiGen code generator will generate code for Transfer object, REST service handling and data access and so on. From 5675dd5702874296cca688bfab877112ecbeb616 Mon Sep 17 00:00:00 2001 From: dixyushi <72491437+dixyushi@users.noreply.github.com> Date: Thu, 11 Nov 2021 11:03:56 +0530 Subject: [PATCH 7/7] modified file