Skip to content

Commit c964694

Browse files
Merge pull request #47 from MarcelDiessner/CobigenJavaBackend
Cobigen java backend
2 parents 3fe112b + 4e2a859 commit c964694

3 files changed

Lines changed: 26 additions & 12 deletions

File tree

cobigen/files/Placeholder.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
private int age;
2+
private String company;
3+
4+
public String getCompany() {
5+
return company;
6+
}
7+
public void setCompany(String company) {
8+
this.company = company;
9+
}
Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
= CobiGen Cli
1+
= Tutorial for Java Backend Generation with CobiGen
22
====
3-
CobiGen is a generic incremental code generator. It allows you build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class.
3+
CobiGen is a generic incremental code generator. It allows you to build Java CRUD application based on the devonfw architecture including all software layers. You can generate all necessary classes and services (DAOs, Transfer Objects, simple CRUD use cases with REST services) of the application from one single entity class.
44
5-
CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands. In this scenario, you will learn how to install and use the cobigen cli inside a java project.
5+
CobiGen provides Maven and Eclipse integrations. But there is also a command line interface (CLI) which enables the generation of code using only few commands.
66
77
More information about CobiGen on https://devonfw.com/website/pages/docs/master-cobigen.asciidoc.html
88
====
99

10-
To use the cobigen cli you first have to install the devonfw ide. You will find more information about devonfw on https://devonfw.com/website/pages/welcome/welcome.html.
1110
[step]
1211
--
13-
installDevonfwIde(["java","mvn"])
12+
restoreDevonfwIde(["java","mvn"])
1413
--
1514

16-
Now, you have to download cobigen
15+
For this tutorial an installation of the devonfw IDE is required, which was already set up for you.
16+
To begin you need to install CobiGen and create a Java Project.
1717
[step]
18+
== Install CobiGen and create Java Project
1819
--
1920
installCobiGen()
20-
--
21-
22-
Now you are ready to create your first project
23-
[step]
24-
--
2521
createDevon4jProject("cobigenexample")
2622
--
2723

@@ -31,7 +27,7 @@ Create the entity class which will be passed to the cobigen cli generator later
3127
createFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java", "files/CustomerEntity.java")
3228
--
3329

34-
Build the java project
30+
Now Build the java project
3531
[step]
3632
--
3733
buildJava("cobigenexample", false)
@@ -41,6 +37,7 @@ buildJava("cobigenexample", false)
4137
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.
4238
[step]
4339
--
40+
adaptTemplatesCobiGen()
4441
cobiGenJava("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8])
4542
--
4643
The CobiGen code generator will generate some java classes for you. These contain code for basic CRUD operations, REST service handling and data access.
@@ -68,3 +65,11 @@ For example, the following files are generated by CobiGen when using the specifi
6865
(8) CRUD SpringData Repository: Generates the entity repository (that contains the CRUD operations) in the data access layer.
6966
- `devonfw/workspaces/main/cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/repo/CustomerRepository.java`{{open}}
7067
====
68+
69+
Furthermore, we can change the CustomerEntity afterwards and update our source files simply by running cobigen again.
70+
[step]
71+
== Change Entity and run cobigen again
72+
--
73+
changeFile("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java", { "file": "files/Placeholder.java", "placeholder": "private int age;" })
74+
cobiGenJava("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8])
75+
--

0 commit comments

Comments
 (0)