148 lines
3.6 KiB
Java
148 lines
3.6 KiB
Java
package eu.eudat.migration.entities;
|
|
|
|
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
|
import org.hibernate.annotations.LazyCollection;
|
|
import org.hibernate.annotations.LazyCollectionOption;
|
|
|
|
import javax.persistence.*;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Entity
|
|
@Table(name = "phases")
|
|
public class Phase {
|
|
|
|
@Id
|
|
private Long id;
|
|
private String title;
|
|
private String description;
|
|
private Long number;
|
|
@Column(name = "created_at")
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
private Date createdAt;
|
|
@Column(name = "updated_at")
|
|
@Temporal(TemporalType.TIMESTAMP)
|
|
private Date updatedAt;
|
|
private Boolean modifiable;
|
|
@Column(name = "versionable_id")
|
|
private String versionableId;
|
|
@OneToMany(cascade = CascadeType.ALL)
|
|
@JoinColumn(name = "phase_id")
|
|
@OrderBy("number")
|
|
@LazyCollection(LazyCollectionOption.FALSE)
|
|
private List<RoadmapSection> sections = new ArrayList<>();
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Phase{" +
|
|
"id=" + id +
|
|
", title='" + title + '\'' +
|
|
", description='" + description + '\'' +
|
|
", number=" + number +
|
|
", createdAt=" + createdAt +
|
|
", updatedAt=" + updatedAt +
|
|
", modifiable=" + modifiable +
|
|
", versionableId='" + versionableId + '\'' +
|
|
", sections=" + sections +
|
|
'}';
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Long 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 Long getNumber() {
|
|
return number;
|
|
}
|
|
|
|
public void setNumber(Long number) {
|
|
this.number = number;
|
|
}
|
|
|
|
|
|
public Date getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(Date createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
|
|
public Date getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(Date updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
|
|
public Boolean getModifiable() {
|
|
return modifiable;
|
|
}
|
|
|
|
public void setModifiable(Boolean modifiable) {
|
|
this.modifiable = modifiable;
|
|
}
|
|
|
|
|
|
public String getVersionableId() {
|
|
return versionableId;
|
|
}
|
|
|
|
public void setVersionableId(String versionableId) {
|
|
this.versionableId = versionableId;
|
|
}
|
|
|
|
public List<RoadmapSection> getSections() {
|
|
return sections;
|
|
}
|
|
|
|
public void setSections(List<RoadmapSection> sections) {
|
|
this.sections = sections;
|
|
}
|
|
|
|
public List<Section> buildSections(String pageId) {
|
|
return sections.stream().map(s -> {
|
|
Section section = new Section();
|
|
section.setId(String.valueOf(UUID.randomUUID()));
|
|
section.setPage(pageId);
|
|
section.setTitle(s.getTitle());
|
|
section.setDescription(s.getDescription());
|
|
section.setOrdinal(Math.toIntExact(s.getNumber()) - 1);
|
|
section.setDefaultVisibility(true);
|
|
section.setMultiplicity(false);
|
|
section.setSections(new ArrayList<>());
|
|
section.setFieldSets(s.buildFieldSets(s.getQuestions()));
|
|
return section;
|
|
}).collect(Collectors.toList());
|
|
}
|
|
}
|