' +
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
+ <#if !attribute.multi>
'' + (${entityNameLowerCase}?.${attribute.name}?.${model.getEntity(attribute.type).getDisplayName()} || '') + ' | ' +
#if>
<#else>
@@ -118,11 +127,10 @@
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
- function load${attribute.getTitleCasePluralizeName()}() {
+ <#if !attribute.multi>
+ function load${attribute.getTitleCaseName()}() {
$.ajax({
- url: 'resources/api/${attribute.name}',
+ url: 'resources/api/${attribute.getApiUrl()}',
method: 'GET',
contentType: 'application/json',
success: function (data) {
@@ -135,7 +143,7 @@
}
});
}
- load${attribute.getTitleCasePluralizeName()}();
+ load${attribute.getTitleCaseName()}();
#if>
#if>
#list>
@@ -150,9 +158,8 @@
$('#${entityNameLowerCase}Modal').modal('show');
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
- load${attribute.getTitleCasePluralizeName()}();
+ <#if !attribute.multi>
+ load${attribute.getTitleCaseName()}();
#if>
#if>
#list>
@@ -164,8 +171,7 @@
var ${entityNameLowerCase} = {
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
+ <#if !attribute.multi>
${attribute.name}: {
${model.getEntity(attribute.type).getPrimaryKeyName()}: $('#${attribute.name}Select').val()
},
@@ -195,8 +201,7 @@
var ${entityNameLowerCase} = {
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
+ <#if !attribute.multi>
${attribute.name}: {
${model.getEntity(attribute.type).getPrimaryKeyName()}: $('#${attribute.name}Select').val()
},
@@ -228,8 +233,7 @@
success: function (${entityNameLowerCase}) {
<#list entity.attributes as attribute>
<#if model.getEntity(attribute.type)??>
- <#if attribute.multi>
- <#else>
+ <#if !attribute.multi>
$('#${attribute.name}Select').val(${entityNameLowerCase}?.${attribute.name}?.${model.getEntity(attribute.type).getPrimaryKeyName()});
#if>
<#else>
diff --git a/starter-generator/src/main/resources/template/rest/EntityController.java.ftl b/starter-generator/src/main/resources/template/rest/EntityController.java.ftl
index b869048..3487a57 100644
--- a/starter-generator/src/main/resources/template/rest/EntityController.java.ftl
+++ b/starter-generator/src/main/resources/template/rest/EntityController.java.ftl
@@ -21,7 +21,7 @@ import ${EntityRepository_FQN};
<#if model.getEntity(attribute.type)??>
<#if attribute.multi>
<#else>
-import ${EntityRepository_package}.${attribute.getTitleCaseName()}${EntityRepositorySuffix};
+import ${EntityRepository_package}.${attribute.getType()}${EntityRepositorySuffix};
#if>
<#else>
#if>
@@ -68,7 +68,7 @@ public class ${controllerClass} {
<#if attribute.multi>
<#else>
@Inject
- private ${attribute.getTitleCaseName()}${EntityRepositorySuffix} ${attribute.name}${EntityRepositorySuffix};
+ private ${attribute.getType()}${EntityRepositorySuffix} ${attribute.name}${EntityRepositorySuffix};
#if>
<#else>
#if>
@@ -98,10 +98,10 @@ public class ${controllerClass} {
<#if model.getEntity(attribute.type)??>
<#if attribute.multi>
<#else>
- if (${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}() != null && ${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}() != null) {
- ${instanceName}.set${model.getEntity(attribute.type).getTitleCaseName()}(${attribute.name}${EntityRepositorySuffix}.find(${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}()));
+ if (${instanceName}.get${attribute.getTitleCaseName()}() != null && ${instanceName}.get${attribute.getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}() != null) {
+ ${instanceName}.set${attribute.getTitleCaseName()}(${attribute.name}${EntityRepositorySuffix}.find(${instanceName}.get${attribute.getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}()));
} else {
- ${instanceName}.set${model.getEntity(attribute.type).getTitleCaseName()}(null);
+ ${instanceName}.set${attribute.getTitleCaseName()}(null);
}
#if>
<#else>
@@ -136,10 +136,10 @@ public class ${controllerClass} {
<#if model.getEntity(attribute.type)??>
<#if attribute.multi>
<#else>
- if (${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}() != null && ${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}() != null) {
- ${instanceName}.set${model.getEntity(attribute.type).getTitleCaseName()}(${attribute.name}${EntityRepositorySuffix}.find(${instanceName}.get${model.getEntity(attribute.type).getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}()));
+ if (${instanceName}.get${attribute.getTitleCaseName()}() != null && ${instanceName}.get${attribute.getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}() != null) {
+ ${instanceName}.set${attribute.getTitleCaseName()}(${attribute.name}${EntityRepositorySuffix}.find(${instanceName}.get${attribute.getTitleCaseName()}().get${model.getEntity(attribute.type).getPrimaryKeyFirstUpperName()}()));
} else {
- ${instanceName}.set${model.getEntity(attribute.type).getTitleCaseName()}(null);
+ ${instanceName}.set${attribute.getTitleCaseName()}(null);
}
#if>
<#else>
diff --git a/starter-ui/pom.xml b/starter-ui/pom.xml
index f3d5a40..acd2cf9 100644
--- a/starter-ui/pom.xml
+++ b/starter-ui/pom.xml
@@ -41,14 +41,14 @@
4.0.0
payara-starter-ui
- 1.0-beta11
+ 1.0-beta12
war
Payara Starter UI
Payara Starter UI
fish.payara.starter
payara-starter-parent
- 1.0-beta11
+ 1.0-beta12
../pom.xml
diff --git a/starter-ui/src/main/java/fish/payara/starter/ERDiagramPlainChat.java b/starter-ui/src/main/java/fish/payara/starter/ERDiagramPlainChat.java
index ad69723..8afc13e 100644
--- a/starter-ui/src/main/java/fish/payara/starter/ERDiagramPlainChat.java
+++ b/starter-ui/src/main/java/fish/payara/starter/ERDiagramPlainChat.java
@@ -306,6 +306,7 @@ Attributes may also have a key or comment defined. Keys can be PK, FK or UK, for
HTML label should not be the same as the attribute name by spliting with space; it should provide more meaning and description.
Invalid Example: For date appointmentDate dont' add htmllabel=Appointment Date, Not required for appointmentDate as it is self descriptive
3(b) Each entity must have only one label or name attribute. Add a 'display=true' property to the attribute that will serve as the label for the entity.
+ Do not add the 'display=true' property to primary-key attribute.
Do not add the 'display=true' property to more than one attribute.
Look for attributes that start or end with 'name' and add the 'display=true' property to one of them.
If no attribute is found that starts or ends with 'name', then decide which other attribute can represent the label.
@@ -314,7 +315,7 @@ Attributes may also have a key or comment defined. Keys can be PK, FK or UK, for
Do not add to Primary key PK.
3(d) Add 'tooltip=description of attribute' to attribute to show it on html input UI which will help end user.
tooltip must be added to all attributes except FK or PK primary key.
- 4- Add variable name to relation of JPA Entities with property relationshipVarNameInFirstEntity and relationshipVarNameInSecondEntity.
+ 4- Add variable name to relation of JPA Entities with property relationshipVarNameInFirstEntity and relationshipVarNameInSecondEntity based on the value of relationshipLabel.
Sample JSON Structure:
{
diff --git a/starter-ui/src/main/java/fish/payara/starter/ERDiagramResource.java b/starter-ui/src/main/java/fish/payara/starter/ERDiagramResource.java
index 8cda1d6..680f325 100644
--- a/starter-ui/src/main/java/fish/payara/starter/ERDiagramResource.java
+++ b/starter-ui/src/main/java/fish/payara/starter/ERDiagramResource.java
@@ -63,24 +63,24 @@ public String generateERDiagram(@QueryParam("request") String request) {
}
}
- @POST
+ @POST
@Consumes(MediaType.TEXT_PLAIN)
@Path(value = "/enlarge")
public String enlargeERDiagramSize(@QueryParam(value = "name") String diagramName, String erDiagram) {
try {
- if (erDiagram != null && !erDiagram.isBlank()
- && diagramName != null && !diagramName.isBlank()) {
- return langChainChatService.enlargeERDiagramSuggestion(diagramName, erDiagram);
- } else {
- throw new BadRequestException("Please provide the diagram");
- }
- } catch(Exception e) {
+ if (erDiagram != null && !erDiagram.isBlank()
+ && diagramName != null && !diagramName.isBlank()) {
+ return langChainChatService.enlargeERDiagramSuggestion(diagramName, erDiagram);
+ } else {
+ throw new BadRequestException("Please provide the diagram");
+ }
+ } catch (Exception e) {
e.printStackTrace();
throw e;
}
}
- @POST
+ @POST
@Consumes(MediaType.TEXT_PLAIN)
@Path("/shrink")
public String shrinkERDiagramSize(@QueryParam("name") String diagramName, String erDiagram) {
@@ -91,8 +91,8 @@ public String shrinkERDiagramSize(@QueryParam("name") String diagramName, String
throw new BadRequestException("Please provide the diagram");
}
}
-
- @POST
+
+ @POST
@Consumes(MediaType.TEXT_PLAIN)
@Path("/update")
public String updateERDiagramSize(@QueryParam("request") String userRequest, String erDiagram) {
diff --git a/starter-ui/src/main/java/fish/payara/starter/resources/ApplicationGenerator.java b/starter-ui/src/main/java/fish/payara/starter/resources/ApplicationGenerator.java
index aba9659..2636af8 100644
--- a/starter-ui/src/main/java/fish/payara/starter/resources/ApplicationGenerator.java
+++ b/starter-ui/src/main/java/fish/payara/starter/resources/ApplicationGenerator.java
@@ -84,6 +84,8 @@
import org.apache.maven.cli.MavenCli;
import jakarta.json.bind.Jsonb;
import jakarta.json.bind.JsonbBuilder;
+import java.nio.file.Path;
+import java.nio.file.Paths;
/**
*
@@ -100,7 +102,7 @@ public class ApplicationGenerator {
private static final String WORKING_DIR_PREFIX = "payara-starter-";
private static final String ARCHETYPE_GROUP_ID = "fish.payara.starter";
private static final String ARCHETYPE_ARTIFACT_ID = "payara-starter-archetype";
- private static final String ARCHETYPE_VERSION = "1.0-beta11";
+ private static final String ARCHETYPE_VERSION = "1.0-beta12";
private static final String MAVEN_ARCHETYPE_CMD = "org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate";// "archetype:generate";
private static final String ZIP_EXTENSION = ".zip";
@@ -159,6 +161,8 @@ public Future generate(ApplicationConfiguration appProperties) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, "Error generating application: {0}", e.getMessage());
}
+ Path diagramPath = Paths.get(applicationDir.getAbsolutePath(), appProperties.getErDiagramName().trim().replaceAll("\\s+", "_") + ".mmd");
+ Files.write(diagramPath, appProperties.getErDiagram().getBytes());
}
return zipDirectory(applicationDir, workingDirectory);
} catch (Exception ie) {