Merge branch '55-new-conf' into 'dev'
Resolve "Добавление новой конференции" Closes #55 See merge request romanov73/ng-tracker!43environments/staging/deployments/16
commit
7dca991c2f
@ -1,11 +1,143 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.Fetch;
|
||||||
|
import org.hibernate.annotations.FetchMode;
|
||||||
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
import ru.ulstu.core.model.BaseEntity;
|
import ru.ulstu.core.model.BaseEntity;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.Paper;
|
||||||
|
import ru.ulstu.user.model.User;
|
||||||
|
|
||||||
|
import javax.persistence.CascadeType;
|
||||||
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.ManyToMany;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OrderBy;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "conference")
|
@Table(name = "conference")
|
||||||
public class Conference extends BaseEntity {
|
public class Conference extends BaseEntity {
|
||||||
|
|
||||||
|
@NotBlank
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private int ping;
|
||||||
|
|
||||||
|
@Column(name = "begin_date")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date beginDate;
|
||||||
|
|
||||||
|
@Column(name = "end_date")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endDate;
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "conference_id", unique = true)
|
||||||
|
@Fetch(FetchMode.SUBSELECT)
|
||||||
|
@OrderBy("date")
|
||||||
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
@JoinTable(name = "paper_conference",
|
||||||
|
joinColumns = {@JoinColumn(name = "conference_id")},
|
||||||
|
inverseJoinColumns = {@JoinColumn(name = "paper_id")})
|
||||||
|
private Set<Paper> papers = new HashSet<>();
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
@JoinTable(name = "users_conference",
|
||||||
|
joinColumns = {@JoinColumn(name = "conference_id")},
|
||||||
|
inverseJoinColumns = {@JoinColumn(name = "users_id")})
|
||||||
|
private Set<User> users = new HashSet<>();
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPing() {
|
||||||
|
return ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPing(int ping) {
|
||||||
|
this.ping = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBeginDate() {
|
||||||
|
return beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginDate(Date beginDate) {
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Deadline> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<Deadline> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Paper> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapers(Set<Paper> papers) {
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<User> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(Set<User> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,197 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import ru.ulstu.deadline.model.Deadline;
|
||||||
|
import ru.ulstu.paper.model.PaperDto;
|
||||||
|
import ru.ulstu.user.model.UserDto;
|
||||||
|
|
||||||
|
import javax.persistence.Temporal;
|
||||||
|
import javax.persistence.TemporalType;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||||
|
|
||||||
public class ConferenceDto {
|
public class ConferenceDto {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
@NotEmpty
|
||||||
|
@Size(min = 2, max = 400)
|
||||||
|
private String title;
|
||||||
|
@Size(max = 500)
|
||||||
|
private String description = "";
|
||||||
|
@Size(max = 255)
|
||||||
|
private String url = "";
|
||||||
|
private int ping = 0;
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date beginDate = new Date();
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
|
private Date endDate = new Date();
|
||||||
|
@NotEmpty
|
||||||
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
|
private Set<Integer> userIds = new HashSet<>();
|
||||||
|
private Set<Integer> paperIds = new HashSet<>();
|
||||||
|
private Set<PaperDto> papers = new HashSet<>();
|
||||||
|
private Set<UserDto> users = new HashSet<>();
|
||||||
|
private Integer filterUserId;
|
||||||
|
|
||||||
|
public ConferenceDto() {
|
||||||
|
deadlines.add(new Deadline());
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonCreator
|
||||||
|
public ConferenceDto(@JsonProperty("id") Integer id,
|
||||||
|
@JsonProperty("title") String title,
|
||||||
|
@JsonProperty("description") String description,
|
||||||
|
@JsonProperty("url") String url,
|
||||||
|
@JsonProperty("ping") Integer ping,
|
||||||
|
@JsonProperty("beginDate") Date beginDate,
|
||||||
|
@JsonProperty("endDate") Date endDate,
|
||||||
|
@JsonProperty("deadlines") List<Deadline> deadlines,
|
||||||
|
@JsonProperty("userIds") Set<Integer> userIds,
|
||||||
|
@JsonProperty("paperIds") Set<Integer> paperIds,
|
||||||
|
@JsonProperty("users") Set<UserDto> users,
|
||||||
|
@JsonProperty("papers") Set<PaperDto> papers) {
|
||||||
|
this.id = id;
|
||||||
|
this.title = title;
|
||||||
|
this.description = description;
|
||||||
|
this.url = url;
|
||||||
|
this.ping = ping;
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
this.endDate = endDate;
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
this.userIds = userIds;
|
||||||
|
this.paperIds = paperIds;
|
||||||
|
this.users = users;
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceDto(Conference conference) {
|
||||||
|
this.id = conference.getId();
|
||||||
|
this.title = conference.getTitle();
|
||||||
|
this.description = conference.getDescription();
|
||||||
|
this.url = conference.getUrl();
|
||||||
|
this.ping = conference.getPing();
|
||||||
|
this.beginDate = conference.getBeginDate();
|
||||||
|
this.endDate = conference.getEndDate();
|
||||||
|
this.deadlines = conference.getDeadlines();
|
||||||
|
this.userIds = convert(conference.getUsers(), user -> user.getId());
|
||||||
|
this.paperIds = convert(conference.getPapers(), paper -> paper.getId());
|
||||||
|
this.users = convert(conference.getUsers(), UserDto::new);
|
||||||
|
this.papers = convert(conference.getPapers(), PaperDto::new);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPing() {
|
||||||
|
return ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPing(int ping) {
|
||||||
|
this.ping = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBeginDate() {
|
||||||
|
return beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeginDate(Date beginDate) {
|
||||||
|
this.beginDate = beginDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getEndDate() {
|
||||||
|
return endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(Date endDate) {
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Deadline> getDeadlines() {
|
||||||
|
return deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeadlines(List<Deadline> deadlines) {
|
||||||
|
this.deadlines = deadlines;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getUserIds() {
|
||||||
|
return userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserIds(Set<Integer> userIds) {
|
||||||
|
this.userIds = userIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getPaperIds() {
|
||||||
|
return paperIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaperIds(Set<Integer> paperIds) {
|
||||||
|
this.paperIds = paperIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<PaperDto> getPapers() {
|
||||||
|
return papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPapers(Set<PaperDto> papers) {
|
||||||
|
this.papers = papers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<UserDto> getUsers() {
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsers(Set<UserDto> users) {
|
||||||
|
this.users = users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFilterUserId() {
|
||||||
|
return filterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterUserId(Integer filterUserId) {
|
||||||
|
this.filterUserId = filterUserId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,47 @@
|
|||||||
package ru.ulstu.conference.model;
|
package ru.ulstu.conference.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ConferenceFilterDto {
|
public class ConferenceFilterDto {
|
||||||
|
|
||||||
|
private List<ConferenceDto> conferences;
|
||||||
|
private Integer filterAuthorId;
|
||||||
|
private Integer year;
|
||||||
|
|
||||||
|
public ConferenceFilterDto() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos, Integer filterAuthorId, Integer year) {
|
||||||
|
this.conferences = conferenceDtos;
|
||||||
|
this.filterAuthorId = filterAuthorId;
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConferenceFilterDto(List<ConferenceDto> conferenceDtos) {
|
||||||
|
this(conferenceDtos, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ConferenceDto> getConferences() {
|
||||||
|
return conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConferences(List<ConferenceDto> conferences) {
|
||||||
|
this.conferences = conferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getFilterAuthorId() {
|
||||||
|
return filterAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilterAuthorId(Integer filterAuthorId) {
|
||||||
|
this.filterAuthorId = filterAuthorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYear(Integer year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue