-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
248 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
create type attachment_data_type as enum ('url', 'storage'); | ||
|
||
create table if not exists attachment_groups( | ||
id integer primary key default nextval('hibernate_sequence'), | ||
code varchar(255) not null unique, | ||
label varchar(255) not null | ||
); | ||
|
||
create table if not exists attachment_types( | ||
id integer primary key default nextval('hibernate_sequence'), | ||
code varchar(255) not null, | ||
label varchar(255) not null, | ||
attachment_group_id integer references attachment_groups(id), | ||
datatype attachment_data_type, | ||
unique(code, attachment_group_id) | ||
); | ||
|
||
create table if not exists attachments( | ||
id integer primary key default nextval('hibernate_sequence'), | ||
|
||
nodeid integer not null, | ||
|
||
ordering integer default 0, | ||
weight integer default 0, | ||
description varchar(255), | ||
|
||
attachment_group varchar(255), | ||
attachment_type varchar(255), | ||
attachment_datatype varchar(255), | ||
attachment_type_id integer references attachment_types(id), | ||
|
||
attachment_data varchar(4096), | ||
|
||
created timestamptz not null default CURRENT_TIMESTAMP, | ||
updated timestamptz not null default CURRENT_TIMESTAMP, | ||
update_userid integer references users(id) | ||
updated timestamptz not null default CURRENT_TIMESTAMP | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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 de.holarse.backend.db; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
|
||
@Table(name = "attachments") | ||
@Entity | ||
public class Attachment extends TimestampedBase { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Column(name = "nodeid") | ||
private Integer nodeId; | ||
|
||
@Column | ||
private int weight; | ||
|
||
@Column(length = 255) | ||
private String description; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="attachment_type_id", nullable=false, referencedColumnName = "id") | ||
private AttachmentGroup group; | ||
|
||
@Column(name = "attachment_data", length = 4096) | ||
private String data; | ||
|
||
public Integer getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
public void setNodeId(Integer nodeId) { | ||
this.nodeId = nodeId; | ||
} | ||
|
||
public int getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(int weight) { | ||
this.weight = weight; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public AttachmentGroup getGroup() { | ||
return group; | ||
} | ||
|
||
public void setGroup(AttachmentGroup group) { | ||
this.group = group; | ||
} | ||
|
||
public String getData() { | ||
return data; | ||
} | ||
|
||
public void setData(String data) { | ||
this.data = data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.holarse.backend.db; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
|
||
@Table(name = "attachment_groups") | ||
@Entity | ||
public class AttachmentGroup extends Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Column(length = 255) | ||
private String code; | ||
@Column(length = 255) | ||
private String label; | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package de.holarse.backend.db; | ||
|
||
import de.holarse.backend.types.AttachmentDataType; | ||
import io.hypersistence.utils.hibernate.type.basic.PostgreSQLEnumType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import org.hibernate.annotations.Type; | ||
|
||
@Entity | ||
@Table(name = "attachment_types") | ||
public class AttachmentType extends Base { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Column(length = 255) | ||
private String code; | ||
|
||
@Column(length = 255) | ||
private String label; | ||
|
||
@ManyToOne | ||
@JoinColumn(name="attachment_group_id", nullable=false, referencedColumnName = "id") | ||
private AttachmentGroup attachmentGroup; | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Type(PostgreSQLEnumType.class) | ||
@Column(columnDefinition = "attachment_data_type", name = "datatype") | ||
private AttachmentDataType dataType; | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(String code) { | ||
this.code = code; | ||
} | ||
|
||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
public void setLabel(String label) { | ||
this.label = label; | ||
} | ||
|
||
public AttachmentGroup getAttachmentGroup() { | ||
return attachmentGroup; | ||
} | ||
|
||
public void setAttachmentGroup(AttachmentGroup attachmentGroup) { | ||
this.attachmentGroup = attachmentGroup; | ||
} | ||
|
||
public AttachmentDataType getDataType() { | ||
return dataType; | ||
} | ||
|
||
public void setDataType(AttachmentDataType dataType) { | ||
this.dataType = dataType; | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/de/holarse/backend/types/AttachmentDataType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package de.holarse.backend.types; | ||
|
||
public enum AttachmentDataType { | ||
|
||
url, | ||
storage | ||
|
||
} |