diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/AttributeEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/AttributeEntity.java index efec234..4b4da40 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/model/AttributeEntity.java +++ b/src/main/java/net/onelitefeather/vulpes/api/model/AttributeEntity.java @@ -4,7 +4,14 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import net.onelitefeather.vulpes.api.generator.VulpesGenerator; +import net.onelitefeather.vulpes.api.model.project.ProjectEntity; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import java.util.UUID; @@ -18,6 +25,9 @@ *
*/ @Entity(name = "attributes") +@Table(name = "attributes", indexes = { + @Index(name = "idx_attributes_project_id", columnList = "project_id") +}) public class AttributeEntity implements VulpesModel { @Id @@ -28,6 +38,10 @@ public class AttributeEntity implements VulpesModel { private String variableName; private double defaultValue; private double maximumValue; + @ManyToOne + @JoinColumn(name = "project_id", nullable = false) + @OnDelete(action = OnDeleteAction.CASCADE) + private ProjectEntity project; /** * Default constructor for JPA and Micronaut Data. @@ -42,18 +56,20 @@ public AttributeEntity() { /** * Constructs a new {@link AttributeEntity} with the specified values. * - * @param id the unique identifier of the attribute - * @param uiName the model name associated with the attribute - * @param variableName the name of the attribute - * @param defaultValue the default value of the attribute - * @param maximumValue the maximum value of the attribute + * @param id the unique identifier of the attribute + * @param uiName the model name associated with the attribute + * @param variableName the name of the attribute + * @param defaultValue the default value of the attribute + * @param maximumValue the maximum value of the attribute + * @param project the project this attribute belongs to */ - public AttributeEntity(UUID id, String uiName, String variableName, double defaultValue, double maximumValue) { + public AttributeEntity(UUID id, String uiName, String variableName, double defaultValue, double maximumValue, ProjectEntity project) { this.id = id; this.uiName = uiName; this.variableName = variableName; this.defaultValue = defaultValue; this.maximumValue = maximumValue; + this.project = project; } // Getters and setters for each field @@ -148,6 +164,24 @@ public void setMaximumValue(double maximumValue) { this.maximumValue = maximumValue; } + /** + * Returns the project this attribute belongs to. + * + * @return the project of the attribute + */ + public ProjectEntity getProject() { + return project; + } + + /** + * Sets the project this attribute belongs to. + * + * @param project the project to set + */ + public void setProject(ProjectEntity project) { + this.project = project; + } + /** * Provides a string representation of the AttributeModel * @@ -161,6 +195,7 @@ public String toString() { ", name='" + variableName + '\'' + ", defaultValue=" + defaultValue + ", maximumValue=" + maximumValue + + ", project=" + project + '}'; } } diff --git a/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java b/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java index 8bb0839..b51aa30 100644 --- a/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java +++ b/src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java @@ -5,9 +5,16 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import net.onelitefeather.vulpes.api.generator.VulpesGenerator; import net.onelitefeather.vulpes.api.model.font.FontStringEntity; +import net.onelitefeather.vulpes.api.model.project.ProjectEntity; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import java.util.List; import java.util.UUID; @@ -22,6 +29,9 @@ * */ @Entity(name = "fonts") +@Table(name = "fonts", indexes = { + @Index(name = "idx_fonts_project_id", columnList = "project_id") +}) public class FontEntity implements VulpesModel { @Id @@ -39,6 +49,11 @@ public class FontEntity implements VulpesModel { @OneToMany(mappedBy = "font", cascade = CascadeType.ALL) private List
@@ -61,6 +76,7 @@ public FontEntity() {
* @param height the height of the font
* @param ascent the ascent of the font
* @param chars the list of characters included in the font
+ * @param project the project this font belongs to
*/
public FontEntity(
UUID id,
@@ -71,7 +87,8 @@ public FontEntity(
String comment,
int height,
int ascent,
- List
@@ -71,6 +86,7 @@ public ItemEntity() {
* @param enchantments the enchantments applied to the item
* @param lore the lore associated with the item
* @param flags the flags associated with the item
+ * @param project the project this item belongs to
*/
public ItemEntity(
UUID id,
@@ -84,7 +100,8 @@ public ItemEntity(
int amount,
List
@@ -67,8 +82,9 @@ public SoundEventEntity() {
* @param replace whether to replace an existing sound model
* @param subTitle the subtitle for the sound model
* @param dataEntities the list of sound data entities related to this sound model
+ * @param project the project this sound event belongs to
*/
- public SoundEventEntity(UUID id, String uiName, String variableName, String keyName, boolean replace, String subTitle, List