Project

General

Profile

1
package eu.dnetlib.uoamonitorservice.entities;
2

    
3
import com.fasterxml.jackson.annotation.JsonProperty;
4
import org.springframework.data.annotation.Id;
5

    
6
import java.util.ArrayList;
7
import java.util.Date;
8
import java.util.List;
9

    
10
enum SectionType {
11
    // Do not rename or remove existring values. This may cause problems with already stored values in DB
12
    number, chart,
13
    NUMBER, CHART;
14
}
15

    
16
public class Section<StringOrIndicator> {
17
    @Id
18
    @JsonProperty("_id")
19
    private String id;
20

    
21
    private String title;
22
    private String defaultId;
23
    private String stakeholderAlias;
24
    private SectionType type;
25
    private Date creationDate;
26
    private Date updateDate;
27
    private List<StringOrIndicator> indicators;
28

    
29
    public Section() {}
30

    
31
    public Section(Section section) {
32
        id = section.getId();
33
        title = section.getTitle();
34
        defaultId = section.getDefaultId();
35
        stakeholderAlias = section.getStakeholderAlias();
36
        setType(section.getType());
37
        creationDate = section.getCreationDate();
38
        updateDate = section.getUpdateDate();
39
    }
40

    
41
    public void copyFromDefault(Section defaultSection) {
42
        setTitle(defaultSection.getTitle());
43
        setType(defaultSection.getType());
44
        setDefaultId(defaultSection.id);
45
        setCreationDate(defaultSection.getCreationDate());
46
        setUpdateDate(defaultSection.getUpdateDate());
47
        setIndicators(new ArrayList<>());
48
    }
49

    
50
    public String getId() {
51
        return id;
52
    }
53

    
54
    public void setId(String id) {
55
        this.id = id;
56
    }
57

    
58
    public String getTitle() {
59
        return title;
60
    }
61

    
62
    public void setTitle(String title) {
63
        this.title = title;
64
    }
65

    
66
    public String getDefaultId() {
67
        return defaultId;
68
    }
69

    
70
    public void setDefaultId(String defaultId) {
71
        this.defaultId = defaultId;
72
    }
73

    
74
    public String getStakeholderAlias() {
75
        return stakeholderAlias;
76
    }
77

    
78
    public void setStakeholderAlias(String stakeholderAlias) {
79
        this.stakeholderAlias = stakeholderAlias;
80
    }
81

    
82
    public String getType() {
83
        if(type == null) {
84
            return null;
85
        }
86
        return type.name();
87
    }
88

    
89
    public void setType(String type) {
90
        if(type == null) {
91
            this.type = null;
92
        } else {
93
            SectionType sectionType = SectionType.valueOf(type);
94
            this.type = sectionType;
95
        }
96
    }
97

    
98
    public Date getCreationDate() {
99
        return creationDate;
100
    }
101

    
102
    public void setCreationDate(Date creationDate) {
103
        this.creationDate = creationDate;
104
    }
105

    
106
    public Date getUpdateDate() {
107
        return updateDate;
108
    }
109

    
110
    public void setUpdateDate(Date updateDate) {
111
        this.updateDate = updateDate;
112
    }
113

    
114
    public List<StringOrIndicator> getIndicators() {
115
        return indicators;
116
    }
117

    
118
    public void setIndicators(List<StringOrIndicator> indicators) {
119
        this.indicators = indicators;
120
    }
121
}
(5-5/9)