Skip to content

Commit d447c4b

Browse files
changed cobiGenJava command
1 parent abdcf4a commit d447c4b

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

engine/command.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export class Command{
33
public parameterString: string;
44

55
get parameters(): any[] {
6-
let params = JSON.parse("[" + this.parameterString + "]");
7-
return params;
6+
return JSON.parse("[" + this.parameterString + "]");
87
}
98
}

playbooks/cobigen-cli/index.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ installCobiGen()
2323
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.
2424
[step]
2525
--
26-
cobiGenJava("Test.java",[1,2,3,4])
26+
cobiGenJava("cobigenexample/core/src/main/java/com/example/application/cobigenexample/customermanagement/dataaccess/api/CustomerEntity.java",[1,3,5,6,8])
2727
--
28+
The CobiGen code generator will generate some java class for you. These contain code for basic CRUD operations, REST service handling and data access.
2829
====

runners/katacoda/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ export class Katacoda extends Runner {
9898
let params = command.parameters;
9999
let cobiGenTemplates = params[1].join(",");
100100

101+
let javaFilePath = new String(params[0]);
102+
let entity = javaFilePath.slice(javaFilePath.lastIndexOf("/") + 1, javaFilePath.lastIndexOf(".")).replace("Entity", "");
103+
104+
// remove the last two directories of the path to the entity class
105+
let tmpPath = javaFilePath.split("/").splice(0, javaFilePath.match(/\//g).length - 2).join("/");
106+
let generatedFiles = [];
107+
generatedFiles.push("devonfw/workspaces/main/" + tmpPath + "/logic/base/usecase/Abstract" + entity + "Uc.java");
108+
generatedFiles.push("devonfw/workspaces/main/" + tmpPath + "/service/impl/rest/" + entity + "managementRestServiceImpl.java");
109+
generatedFiles.push("devonfw/workspaces/main/" + tmpPath + "/dataaccess/api/repo/" + entity + "Repository.java");
110+
101111
this.renderTemplate(path.join("scripts", "installCobiGenPlugin.sh"), path.join(this.setupDir, "installCobiGenPlugin.sh"), { vsixFile: "cobigen-0.0.1.vsix", pluginName: "cobigen" });
102112
this.setupScripts.push({
103113
"name": "Install CobiGen plugin",
@@ -109,7 +119,7 @@ export class Katacoda extends Runner {
109119
"title": "CobiGen Java",
110120
"text": "step" + this.stepsCount + ".md"
111121
});
112-
this.renderTemplate("cobiGenJava.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, javaFile: params[0], cobiGenTemplates: cobiGenTemplates });
122+
this.renderTemplate("cobiGenJava.md", this.outputPathTutorial + "step" + (this.stepsCount++) + ".md", { text: step.text, textAfter: step.textAfter, javaFile: params[0], cobiGenTemplates: cobiGenTemplates, generatedFiles: generatedFiles });
113123
return null;
114124
}
115125

runners/katacoda/templates/cobiGenJava.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,9 @@ You can choose the templates CobiGen should use by entering the numbers.
1313

1414
`<%= cobiGenTemplates; %>`{{execute}}
1515

16-
<%= textAfter; %>
16+
<%= textAfter; %>
17+
18+
For example, the following files are generated by CobiGen.
19+
<% for(var i=0; i<generatedFiles.length; i++) {%>
20+
`<%=generatedFiles[i]%>`{{open}}
21+
<% } %>

0 commit comments

Comments
 (0)