diff options
author | Vitaly Takmazov | 2024-06-30 23:55:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-06-30 23:55:11 +0300 |
commit | ce61e2143a358d6c187b6c3473ab114c60ab4724 (patch) | |
tree | 8381a7d91751c5ab2eeb78a3a29f514a6bc4c957 /src/main/java/com/juick/data/entities | |
parent | f9fde9b8aaf242704b62d025337393331ff1ce9e (diff) |
Import JPA entities from 2018
Diffstat (limited to 'src/main/java/com/juick/data/entities')
13 files changed, 646 insertions, 0 deletions
diff --git a/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java b/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java new file mode 100644 index 00000000..934cce92 --- /dev/null +++ b/src/main/java/com/juick/data/entities/BaseMessagePropertyEntity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@MappedSuperclass +public class BaseMessagePropertyEntity { + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "message_id") + private MessageEntity message; + public MessageEntity getMessage() { + return message; + } + + public void setMessage(MessageEntity message) { + this.message = message; + } +} diff --git a/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java b/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java new file mode 100644 index 00000000..0397c409 --- /dev/null +++ b/src/main/java/com/juick/data/entities/BaseUserPropertyEntity.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@MappedSuperclass +public class BaseUserPropertyEntity { + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private UserEntity user; + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } +} diff --git a/src/main/java/com/juick/data/entities/EmailEntity.java b/src/main/java/com/juick/data/entities/EmailEntity.java new file mode 100644 index 00000000..566a9654 --- /dev/null +++ b/src/main/java/com/juick/data/entities/EmailEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "emails") +public class EmailEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "email", columnDefinition = "char(64)") + @GeneratedValue(strategy = GenerationType.AUTO) + private String email; + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/src/main/java/com/juick/data/entities/FacebookEntity.java b/src/main/java/com/juick/data/entities/FacebookEntity.java new file mode 100644 index 00000000..75bee8d8 --- /dev/null +++ b/src/main/java/com/juick/data/entities/FacebookEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "facebook") +public class FacebookEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "fb_id", columnDefinition = "bigint(20)") + @GeneratedValue(strategy = GenerationType.AUTO) + private Long facebookId; + + public Long getFacebookId() { + return facebookId; + } + + public void setFacebookId(Long facebookId) { + this.facebookId = facebookId; + } +} diff --git a/src/main/java/com/juick/data/entities/LoginEntity.java b/src/main/java/com/juick/data/entities/LoginEntity.java new file mode 100644 index 00000000..69737b5d --- /dev/null +++ b/src/main/java/com/juick/data/entities/LoginEntity.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "logins") +public class LoginEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "hash", columnDefinition = "char(16)") + private String hash; + + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } +} diff --git a/src/main/java/com/juick/data/entities/MessageEntity.java b/src/main/java/com/juick/data/entities/MessageEntity.java new file mode 100644 index 00000000..8fa751c9 --- /dev/null +++ b/src/main/java/com/juick/data/entities/MessageEntity.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; +import java.io.Serializable; +import java.time.Instant; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "messages") +public class MessageEntity implements Serializable { + @Id + @Column(name = "message_id", columnDefinition = "int(10) unsigned not null auto_increment") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "message") + private Set<TagEntity> tags = new HashSet<>(); + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "message") + private Set<ReplyEntity> replies = new HashSet<>(); + + @OneToOne(cascade = CascadeType.ALL) + @PrimaryKeyJoinColumn + private TextEntity textEntity; + + @ManyToOne(cascade = CascadeType.ALL) + private UserEntity user; + + @Column(name = "ts") + private Instant ts; + + public MessageEntity() { + this.textEntity = new TextEntity(); + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Set<TagEntity> getTags() { + return tags; + } + + public void setTags(Set<TagEntity> tags) { + this.tags = tags; + } + + public Set<ReplyEntity> getReplies() { + return replies; + } + + public void setReplies(Set<ReplyEntity> replies) { + this.replies = replies; + } + + public String getText() { + return textEntity.getText(); + } + + public void setText(String text) { + this.textEntity.setText(text); + } + + public UserEntity getUser() { + return user; + } + + public void setUser(UserEntity user) { + this.user = user; + } + + public Instant getTimestamp() { + return ts; + } + + public void setTimestamp(Instant ts) { + this.ts = ts; + } +} diff --git a/src/main/java/com/juick/data/entities/ReplyEntity.java b/src/main/java/com/juick/data/entities/ReplyEntity.java new file mode 100644 index 00000000..102d9848 --- /dev/null +++ b/src/main/java/com/juick/data/entities/ReplyEntity.java @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "replies") +public class ReplyEntity extends BaseMessagePropertyEntity { + @Id + @Column(name = "reply_id", columnDefinition = "smallint") + @GeneratedValue(strategy = GenerationType.AUTO) + private Long replyId; + @Column(name = "txt", columnDefinition = "clob") + private + String text; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Long getReplyId() { + return replyId; + } + + public void setReplyId(Long replyId) { + this.replyId = replyId; + } +} diff --git a/src/main/java/com/juick/data/entities/TagEntity.java b/src/main/java/com/juick/data/entities/TagEntity.java new file mode 100644 index 00000000..5dddb074 --- /dev/null +++ b/src/main/java/com/juick/data/entities/TagEntity.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "messages_tags") +public class TagEntity extends BaseMessagePropertyEntity { + @Id + @Column(name = "tag_id", columnDefinition = "int(10)") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + @OneToOne(cascade = CascadeType.ALL) + @PrimaryKeyJoinColumn + private TagNameEntity tagName; +} diff --git a/src/main/java/com/juick/data/entities/TagNameEntity.java b/src/main/java/com/juick/data/entities/TagNameEntity.java new file mode 100644 index 00000000..96bcea8e --- /dev/null +++ b/src/main/java/com/juick/data/entities/TagNameEntity.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "tags") +public class TagNameEntity { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "tag_id") + private int id; + @Column(name = "name", columnDefinition = "varchar(70)") + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/src/main/java/com/juick/data/entities/TelegramEntity.java b/src/main/java/com/juick/data/entities/TelegramEntity.java new file mode 100644 index 00000000..b5b4d8ef --- /dev/null +++ b/src/main/java/com/juick/data/entities/TelegramEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "telegram") +public class TelegramEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "tg_id", columnDefinition = "bigint(20)") + @GeneratedValue(strategy = GenerationType.AUTO) + private Long identifier; + + public Long getIdentifier() { + return identifier; + } + + public void setIdentifier(Long identifier) { + this.identifier = identifier; + } +} diff --git a/src/main/java/com/juick/data/entities/TextEntity.java b/src/main/java/com/juick/data/entities/TextEntity.java new file mode 100644 index 00000000..57a1722f --- /dev/null +++ b/src/main/java/com/juick/data/entities/TextEntity.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; +import java.io.Serializable; + +@Entity +@Table(name = "messages_txt") +public class TextEntity implements Serializable { + + @Id + @Column(name = "message_id", columnDefinition = "int(10)") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @Column(name = "txt", columnDefinition = "clob") + private String text; + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } +} diff --git a/src/main/java/com/juick/data/entities/UserEntity.java b/src/main/java/com/juick/data/entities/UserEntity.java new file mode 100644 index 00000000..1984799e --- /dev/null +++ b/src/main/java/com/juick/data/entities/UserEntity.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; +import java.util.HashSet; +import java.util.Set; + +@Entity +@Table(name = "users") +public class UserEntity { + @Id + @Column(name = "id", columnDefinition = "int(10) unsigned not null auto_increment") + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "nick", columnDefinition = "char(64)") + private String name; + + @Column(name = "passw", columnDefinition = "char(32)") + private String password; + + @Column(name = "banned", columnDefinition = "tinyint(1)") + private boolean banned; + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<EmailEntity> emails = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<FacebookEntity> facebookIds = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<VKEntity> vkIds = new HashSet<>(); + + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<LoginEntity> logins = new HashSet<>(); + @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "user") + private Set<TelegramEntity> tgIds = new HashSet<>(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public Integer getId() { + return id; + } + + public void setId(Integer uid) { + this.id = uid; + } + + public boolean isBanned() { + return banned; + } + + public void setBanned(boolean banned) { + this.banned = banned; + } + + public Set<EmailEntity> getEmails() { + return emails; + } + + public void setEmails(Set<EmailEntity> emails) { + this.emails = emails; + } + + public Set<FacebookEntity> getFacebookIds() { + return facebookIds; + } + + public void setFacebookIds(Set<FacebookEntity> facebookIds) { + this.facebookIds = facebookIds; + } + + public Set<VKEntity> getVkIds() { + return vkIds; + } + + public void setVkIds(Set<VKEntity> vkIds) { + this.vkIds = vkIds; + } + + public Set<LoginEntity> getLogins() { + return logins; + } + + public void setLogins(Set<LoginEntity> logins) { + this.logins = logins; + } + + public Set<TelegramEntity> getTgIds() { + return tgIds; + } + + public void setTgIds(Set<TelegramEntity> tgIds) { + this.tgIds = tgIds; + } +} diff --git a/src/main/java/com/juick/data/entities/VKEntity.java b/src/main/java/com/juick/data/entities/VKEntity.java new file mode 100644 index 00000000..04aa55eb --- /dev/null +++ b/src/main/java/com/juick/data/entities/VKEntity.java @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2008-2024, Juick + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package com.juick.data.entities; + +import jakarta.persistence.*; + +@Entity +@Table(name = "vk") +public class VKEntity extends BaseUserPropertyEntity { + @Id + @Column(name = "vk_id", columnDefinition = "bigint(20)") + @GeneratedValue(strategy = GenerationType.AUTO) + private Long vkId; + + public Long getVkId() { + return vkId; + } + + public void setVkId(Long vkId) { + this.vkId = vkId; + } +} |