Skip to content

Commit

Permalink
FISH-9548 Maintain OpenAI state to create ER diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
jGauravGupta committed Oct 8, 2024
1 parent d3a5353 commit 636faf4
Show file tree
Hide file tree
Showing 23 changed files with 808 additions and 492 deletions.
8 changes: 7 additions & 1 deletion PayaraStarterGenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>fish.payara.starter</groupId>
<artifactId>payara-starter-parent</artifactId>
<version>1.0-beta8</version>
<version>1.0-beta9</version>
</parent>
<artifactId>payara-starter-generator</artifactId>
<name>Payara Starter Generator</name>
Expand All @@ -16,6 +16,12 @@
<version>2.3.31</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>10.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
package fish.payara.starter.application.domain;

import fish.payara.starter.application.util.AttributeType;
import static fish.payara.starter.application.util.AttributeType.LOCAL_DATE;
import static fish.payara.starter.application.util.AttributeType.LOCAL_DATE_TIME;
import static fish.payara.starter.application.util.StringHelper.pluralize;
import static fish.payara.starter.application.util.StringHelper.startCase;
import static fish.payara.starter.application.util.StringHelper.titleCase;
import jakarta.json.bind.annotation.JsonbTransient;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -28,51 +31,55 @@
*/
public class Attribute {

private final String name;
private final String type;
private boolean isPrimaryKey;
private String name;
private String type;
private boolean primaryKey;
private boolean required;
private List<String> _import = new ArrayList<>();
private Entity relation;
private boolean multi;
private String tooltip;
private Boolean display;
private String htmlLabel;

private final List<KeyValue> property;
public Attribute() {
}

public Attribute(String name, String type, boolean isPrimaryKey, List<KeyValue> property) {
public Attribute(String name, String type, boolean isPrimaryKey) {
this.name = name;
this.type = type;
this.isPrimaryKey = isPrimaryKey;
this.property = property;
this.primaryKey = isPrimaryKey;
}

public Attribute(String name, Entity relation, boolean multi, List<KeyValue> property) {
public Attribute(String name, boolean multi, String relation) {
this.name = name;
this.type = relation.getName();
this.relation = relation;
this.type = relation;
this.multi = multi;
this.property = property;
}

public String getName() {
return name;
}

@JsonbTransient
public String getStartCaseName() {
return startCase(name);
}

@JsonbTransient
public String getLowerCaseName() {
return name.toLowerCase();
}

@JsonbTransient
public String getTitleCaseName() {
return titleCase(name);
}

@JsonbTransient
public String getLowerCasePluralizeName() {
return pluralize(name.toLowerCase());
}

@JsonbTransient
public String getTitleCasePluralizeName() {
return pluralize(titleCase(name));
}
Expand All @@ -81,71 +88,90 @@ public String getType() {
return type;
}

@JsonbTransient
public boolean isNumber() {
return AttributeType.isNumber(type);
}

public boolean isPrimaryKey() {
return isPrimaryKey;
return primaryKey;
}

@JsonbTransient
public boolean isRequired() {
return required;
}

public void setRequired(boolean required) {
this.required = required;
}

public boolean isMulti() {
return multi;
}

public Entity getRelation() {
return relation;
@JsonbTransient
public String getToolTipText() {
return tooltip;
}

public List<KeyValue> getProperty() {
return property;
@JsonbTransient
public boolean isToolTip() {
return getToolTipText() != null && !getToolTipText().trim().isEmpty();
}

public String getProperty(String key) {
for (KeyValue keyValue : property) {
if (keyValue.getKey().equals(key)) {
return keyValue.getValue();
}
}
return null;
}

public String getProperty(String key, String defaultValue) {
for (KeyValue keyValue : property) {
if (keyValue.getKey().equals(key)) {
return keyValue.getValue() == null ? defaultValue : keyValue.getValue();
}
}
return defaultValue;
public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}

public String getToolTipText() {
return getProperty("tooltip", "");

@JsonbTransient
public String getHtmlLabel() {
return htmlLabel;
}

public boolean isToolTip() {
return !getToolTipText().trim().isEmpty();
public void setHtmlLabel(String htmllabel) {
this.htmlLabel = htmllabel;
}

@JsonbTransient
public Boolean isDisplay() {
return display;
}

public void setDisplay(Boolean display) {
this.display = display;
}

@JsonbTransient
public List<String> getImports() {
List<String> _import = new ArrayList<>();
if (type.equals("LocalDate")) {
_import.add(LOCAL_DATE);
} else if (type.equals("LocalDateTime")) {
_import.add(LOCAL_DATE_TIME);
}
return _import;
}

public boolean addImport(String e) {
return _import.add(e);
public void setName(String name) {
this.name = name;
}

public boolean removeImport(String o) {
return _import.remove(o);
public void setType(String type) {
this.type = type;
}

public void setPrimaryKey(boolean isPrimaryKey) {
this.primaryKey = isPrimaryKey;
}

public void setMulti(boolean multi) {
this.multi = multi;
}

@Override
public String toString() {
return "\n\t\tAttribute{name=" + name + ", type=" + type + ", isPrimaryKey=" + isPrimaryKey + ", property=" + property + '}';
return "\n\t\tAttribute{name=" + name + ", type=" + type + ", isPrimaryKey=" + primaryKey + '}';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package fish.payara.starter.application.domain;

/**
*
* @author Gaurav Gupta
*/
public class Constant {

public static final String icon_default = "circle";
public static final String title_default = "Jakarta EE Sample";
public static final String longTitle_default = "Jakarta EE Sample";
public static final String homePageDescription_default = "Unlock the full potential of your application by harnessing the power of Jakarta EE";
public static final String aboutUsPageDescription_default = "Welcome to our About Us page, where innovation meets reliability with Payara Jakarta EE. As a team passionate about delivering unparalleled solutions, we specialize in harnessing the power of Jakarta EE to create robust, scalable, and secure applications. With a deep understanding of enterprise-grade development, we are committed to crafting tailored solutions that drive business growth and exceed client expectations. Backed by years of experience and a dedication to staying at the forefront of technology, we take pride in our ability to transform ideas into reality, empowering businesses to thrive in the digital landscape. Discover more about our journey, expertise, and the vision that propels us forward.";

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,24 @@
*
* @author Gaurav Gupta
*/
import static fish.payara.starter.application.domain.Constant.aboutUsPageDescription_default;
import static fish.payara.starter.application.domain.Constant.homePageDescription_default;
import static fish.payara.starter.application.domain.Constant.icon_default;
import static fish.payara.starter.application.domain.Constant.longTitle_default;
import static fish.payara.starter.application.domain.Constant.title_default;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jakarta.json.bind.annotation.JsonbTransient;


public class ERModel {

private final List<Entity> entities = new ArrayList<>();
private final List<Relationship> relationships = new ArrayList<>();
private List<KeyValue> property = Collections.EMPTY_LIST;
private List<Entity> entities = new ArrayList<>();
private List<Relationship> relationships = new ArrayList<>();


public ERModel() {
}

public void addEntity(Entity entity) {
entities.add(entity);
Expand All @@ -54,41 +63,79 @@ public List<Relationship> getRelationships() {
return relationships;
}

public List<KeyValue> getProperty() {
return property;
public void setEntities(List<Entity> entities) {
this.entities = entities;
}

public void setProperty(List<KeyValue> property) {
this.property = property;
public void setRelationships(List<Relationship> relationships) {
this.relationships = relationships;
}

public String getProperty(String key, String defaultValue) {
for (KeyValue keyValue : property) {
if (keyValue.getKey().equals(key)) {
return keyValue.getValue() == null ? defaultValue : keyValue.getValue();
}
}
return defaultValue;


private String icon;
private String title;
private String longTitle;
private String homePageDescription;
private String aboutUsPageDescription;
private List<String> topBarMenuOptions = new ArrayList<>();


@JsonbTransient
public String getIcon() {
return icon == null ? icon_default : icon;
}

public String getIcon() {
return getProperty("icon", "circle");
public void setIcon(String icon) {
this.icon = icon;
}

@JsonbTransient
public String getTitle() {
return getProperty("title", "Jakarta EE Sample");
return title == null ? title_default : title;
}

@JsonbTransient
public String getTitle(String defaultValue) {
return title != null ? title : defaultValue;
}

public void setTitle(String title) {
this.title = title;
}

@JsonbTransient
public String getLongTitle() {
return getProperty("long-title", getProperty("title", "EE Sample"));
return longTitle == null ? longTitle_default : longTitle;
}

public void setLongTitle(String longTitle) {
this.longTitle = longTitle;
}

@JsonbTransient
public String getHomePageDescription() {
return homePageDescription == null ? homePageDescription_default : homePageDescription;
}

public void setHomePageDescription(String homePageDescription) {
this.homePageDescription = homePageDescription;
}

@JsonbTransient
public String getAboutUsPageDescription() {
return aboutUsPageDescription == null ? aboutUsPageDescription_default : aboutUsPageDescription;
}

public void setAboutUsPageDescription(String aboutUsPageDescription) {
this.aboutUsPageDescription = aboutUsPageDescription;
}

public String getDescription() {
return getProperty("home-page-description", "Unlock the full potential of your application by harnessing the power of Jakarta EE");
public List<String> getTopBarMenuOptions() {
return topBarMenuOptions;
}

public String getAboutUsDescription() {
return getProperty("about-us-page-description", "Welcome to our About Us page, where innovation meets reliability with Payara Jakarta EE. As a team passionate about delivering unparalleled solutions, we specialize in harnessing the power of Jakarta EE to create robust, scalable, and secure applications. With a deep understanding of enterprise-grade development, we are committed to crafting tailored solutions that drive business growth and exceed client expectations. Backed by years of experience and a dedication to staying at the forefront of technology, we take pride in our ability to transform ideas into reality, empowering businesses to thrive in the digital landscape. Discover more about our journey, expertise, and the vision that propels us forward.");
public void setTopBarMenuOptions(List<String> topBarMenuOptions) {
this.topBarMenuOptions = topBarMenuOptions;
}

@Override
Expand Down
Loading

0 comments on commit 636faf4

Please sign in to comment.