Упростил сущность Issue

This commit is contained in:
Struchkov Mark 2023-01-20 18:36:39 +03:00 committed by DmitrySheyko
parent 7396c2a2ef
commit 35783a55e7
6 changed files with 23 additions and 213 deletions

View File

@ -8,9 +8,24 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -68,10 +83,6 @@ public class Issue {
@Column(name = "labels")
private Set<String> labels = new HashSet<>();
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "milestone_id")
private Milestone milestone;
@Column(name = "assignees")
@OneToMany(
fetch = FetchType.LAZY,
@ -82,7 +93,7 @@ public class Issue {
joinColumns = @JoinColumn(name = "issue_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(name = "person_id", referencedColumnName = "id")
)
private Set<Person> assignees = new HashSet<>();
private List<Person> assignees = new ArrayList<>();
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "author_id")
@ -90,11 +101,7 @@ public class Issue {
@Enumerated(value = EnumType.STRING)
@Column(name = "type")
private IssueType type; // ОБразец приходящего значения "INCIDENT"
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "assignee_id")
private Person assignee;
private IssueType type;
@Column(name = "user_notes_count")
private Integer userNotesCount;
@ -117,65 +124,19 @@ public class Issue {
@Column(name = "discussion_locked")
private Integer discussionLocked;
@Column(name = "issue_type")
private String issueType; //TODO выяснить зачем дублирует поле type Образец приходящего значения "incident"
@Column(name = "task_count")
private Integer taskCount;
@Column(name = "task_completed_count")
private Integer taskCompletedCount;
@Column(name = "web_url")
private String webUrl;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "timeEstimate", column = @Column(name = "time_estimate")),
@AttributeOverride(name = "totalTimeSpent", column = @Column(name = "total_time_spent")),
@AttributeOverride(name = "humanTimeEstimate", column = @Column(name = "human_time_estimate")),
@AttributeOverride(name = "humanTotalTimeSpent", column = @Column(name = "human_total_time_spent"))
})
private TimeStats timeStats;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "count", column = @Column(name = "task_count")),
@AttributeOverride(name = "completedCount", column = @Column(name = "task_completed_count"))
})
private TaskCompletionStatus taskCompletionStatus;
@Column(name = "blocking_issues_count")
private Integer blockingIssuesCount;
@Column(name = "has_tasks")
private Boolean hasTasks;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "self", column = @Column(name = "link_to_self")),
@AttributeOverride(name = "notes", column = @Column(name = "link_to_notes")),
@AttributeOverride(name = "awardEmoji", column = @Column(name = "link_to_award_emoji")),
@AttributeOverride(name = "project", column = @Column(name = "link_to_project")),
@AttributeOverride(name = "closedAsDuplicateOf", column = @Column(name = "link_to_closed_as_duplicate_of"))
})
private Links links;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "shortReference", column = @Column(name = "short_reference")),
@AttributeOverride(name = "relativeReference", column = @Column(name = "relative_reference")),
@AttributeOverride(name = "fullReference", column = @Column(name = "full_reference"))
})
private References references;
/**
Возможно надо заменить на енум: "UNKNOWN", "Critical - S1", "High - S2", "Medium - S3", "Low - S4".
Но выбор любых значений кроме "UNKNOWN" доступен только для премиум акаунтов и я не могу получить точные значения котоые оно принимает.
*/
@Column(name = "severity")
private String severity;
@Column(name = "moved_to_id")
private Long movedToId;
@Column(name = "service_desk_reply_to")
private String serviceDescReplyTo;
@Column(name = "epic_issue_id")
private Long epicId; // "epic_issue_id" Поле доснтупное только для премиум акаунтов
}

View File

@ -1,23 +0,0 @@
package dev.struchkov.bot.gitlab.context.domain.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Embeddable;
/**
* Сущность Issue.
*
* @author Dmitry Sheyko [17.01.2023]
*/
@Embeddable
@Getter
@Setter
public class Links {
private String self;
private String notes;
private String awardEmoji;
private String project;
private String closedAsDuplicateOf;
}

View File

@ -1,64 +0,0 @@
package dev.struchkov.bot.gitlab.context.domain.entity;
import dev.struchkov.bot.gitlab.context.domain.MilestoneState;
import dev.struchkov.haiti.utils.fieldconstants.annotation.FieldNames;
import dev.struchkov.haiti.utils.fieldconstants.domain.Mode;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import java.time.LocalDateTime;
/**
* Сущность Milestone.
*
* @author Dmitry Sheyko 17.01.2023
*/
@Entity
@Getter
@Setter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@Table(name = "milestone")
@FieldNames(mode = {Mode.TABLE, Mode.SIMPLE})
public class Milestone {
@Id
@EqualsAndHashCode.Include
private Long id;
@Column(name = "two_id")
private Long twoId;
@Column(name = "project_id")
private Long projectId;
@Column(name = "title")
private String title;
@Column(name = "description")
private String description;
@Enumerated(value = EnumType.STRING)
@Column(name = "state")
private MilestoneState state;
@Column(name = "created_date")
private LocalDateTime createdDate;
@Column(name = "updated_date")
private LocalDateTime updatedDate;
@Column(name = "start_date")
private LocalDateTime startDate; //установленное создателем время начала
@Column(name = "due_date")
private LocalDateTime dueDate; //установленное создателем время окончания
@Column(name = "expired")
private Boolean expired;
@Column(name = "web_url")
private String webUrl;
}

View File

@ -1,21 +0,0 @@
package dev.struchkov.bot.gitlab.context.domain.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Embeddable;
/**
* Сущность References.
*
* @author Dmitry Sheyko [17.01.2023]
*/
@Embeddable
@Getter
@Setter
public class References {
private String shortReference;
private String relativeReference;
private String fullReference;
}

View File

@ -1,20 +0,0 @@
package dev.struchkov.bot.gitlab.context.domain.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Embeddable;
/**
* Сущность TaskCompletionStatus.
*
* @author Dmitry Sheyko [17.01.2023]
*/
@Embeddable
@Getter
@Setter
public class TaskCompletionStatus {
private Integer count;
private Integer completedCount;
}

View File

@ -1,23 +0,0 @@
package dev.struchkov.bot.gitlab.context.domain.entity;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.Embeddable;
/**
* Сущность TimeStats.
*
* @author Dmitry Sheyko [17.01.2023]
*/
@Embeddable
@Getter
@Setter
public class TimeStats {
private Integer timeEstimate;
private Integer totalTimeSpent; // количество секунд затраченых на работы, пример 37800"
private String humanTimeEstimate;
private String humanTotalTimeSpent; // Время строкой, пример "10h 30m"
}