253 lines
7.6 KiB
Java
253 lines
7.6 KiB
Java
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.name.NameContainer;
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import javax.persistence.Temporal;
|
|
import javax.persistence.TemporalType;
|
|
import javax.validation.constraints.Size;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
|
|
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
|
|
|
public class ConferenceDto extends NameContainer {
|
|
|
|
private final static String BEGIN_DATE = "Начало: ";
|
|
private final static String END_DATE = "Конец: ";
|
|
|
|
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();
|
|
private List<Deadline> deadlines = new ArrayList<>();
|
|
private List<Integer> removedDeadlineIds = new ArrayList<>();
|
|
private List<Integer> userIds = new ArrayList<>();
|
|
private List<Integer> paperIds = new ArrayList<>();
|
|
private List<Paper> papers = new ArrayList<>();
|
|
private List<Paper> notSelectedPapers = new ArrayList<>();
|
|
private List<ConferenceUser> users = new ArrayList<>();
|
|
private boolean disabledTakePart = false;
|
|
|
|
public ConferenceDto() {
|
|
}
|
|
|
|
@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") List<Integer> userIds,
|
|
@JsonProperty("paperIds") List<Integer> paperIds,
|
|
@JsonProperty("users") List<ConferenceUser> users,
|
|
@JsonProperty("papers") List<Paper> papers,
|
|
@JsonProperty("notSelectedPapers") List<Paper> notSelectedPapers,
|
|
@JsonProperty("notSelectedPapers") Boolean disabledTakePart) {
|
|
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;
|
|
this.notSelectedPapers = notSelectedPapers;
|
|
this.disabledTakePart = disabledTakePart;
|
|
}
|
|
|
|
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 = conference.getUsers();
|
|
this.papers = conference.getPapers();
|
|
}
|
|
|
|
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 List<Integer> getUserIds() {
|
|
return userIds;
|
|
}
|
|
|
|
public void setUserIds(List<Integer> userIds) {
|
|
this.userIds = userIds;
|
|
}
|
|
|
|
public List<Integer> getPaperIds() {
|
|
return paperIds;
|
|
}
|
|
|
|
public void setPaperIds(List<Integer> paperIds) {
|
|
this.paperIds = paperIds;
|
|
}
|
|
|
|
public List<Paper> getPapers() {
|
|
return papers;
|
|
}
|
|
|
|
public void setPapers(List<Paper> papers) {
|
|
this.papers = papers;
|
|
}
|
|
|
|
public List<ConferenceUser> getUsers() {
|
|
return users;
|
|
}
|
|
|
|
public void setUsers(List<ConferenceUser> users) {
|
|
this.users = users;
|
|
}
|
|
|
|
public boolean isDisabledTakePart() {
|
|
return disabledTakePart;
|
|
}
|
|
|
|
public void setDisabledTakePart(boolean disabledTakePart) {
|
|
this.disabledTakePart = disabledTakePart;
|
|
}
|
|
|
|
public List<Integer> getRemovedDeadlineIds() {
|
|
return removedDeadlineIds;
|
|
}
|
|
|
|
public void setRemovedDeadlineIds(List<Integer> removedDeadlineIds) {
|
|
this.removedDeadlineIds = removedDeadlineIds;
|
|
}
|
|
|
|
public List<Paper> getNotSelectedPapers() {
|
|
return notSelectedPapers;
|
|
}
|
|
|
|
public void setNotSelectedPapers(List<Paper> notSelectedPapers) {
|
|
this.notSelectedPapers = notSelectedPapers;
|
|
}
|
|
|
|
public String getDatesString() {
|
|
return BEGIN_DATE + beginDate.toString().split(" ")[0] + " " + END_DATE + endDate.toString().split(" ")[0];
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
ConferenceDto that = (ConferenceDto) o;
|
|
return ping == that.ping &&
|
|
disabledTakePart == that.disabledTakePart &&
|
|
Objects.equals(id, that.id) &&
|
|
Objects.equals(title, that.title) &&
|
|
Objects.equals(description, that.description) &&
|
|
Objects.equals(url, that.url) &&
|
|
Objects.equals(deadlines, that.deadlines) &&
|
|
Objects.equals(removedDeadlineIds, that.removedDeadlineIds) &&
|
|
Objects.equals(userIds, that.userIds) &&
|
|
Objects.equals(paperIds, that.paperIds) &&
|
|
Objects.equals(papers, that.papers) &&
|
|
Objects.equals(notSelectedPapers, that.notSelectedPapers) &&
|
|
Objects.equals(users, that.users);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(id, title, description, url, ping, beginDate, endDate, deadlines, removedDeadlineIds,
|
|
userIds, paperIds, papers, notSelectedPapers, users, disabledTakePart);
|
|
}
|
|
}
|